.net - Regex to allow only dots, letters and dashes in VB.NET -
i have code, , dimiss words spaces , starts +... have allow dots, letters , dashes... think more simple:
imports system.text.regularexpressions public class contactos readonly pattern string = "\s([^+\d\,]+),?" private sub button1_click(sender object, e eventargs) handles button1.click dim cadena string = " " & textbox1.text & "," dim match match = regex.match(cadena, pattern) while match.success frmmain.listbox1.items.add(match.groups(1).tostring) match = match.nextmatch() loop end sub end class
what can do?
thanks! :)
please try following pattern "(?<=(^|,\s))(?<word>[\.a-za-z\-]+)($|,)"
, use named group word
expected values:
while match.success frmmain.listbox1.items.add(match.groups("word").tostring) match = match.nextmatch() loop
Comments
Post a Comment