Roberto P. Well-Known Member Licensed User Longtime User Oct 29, 2020 #1 Hi, I ask for help in solving a problem using the regex feature and I can't figure out where I'm wrong !? with this code I get an incorrect result, because almost all the characters are deleted: Code: Copy Dim Matcher1 As Matcher = Regex.Matcher("\d+[A-Z0-9]", aReader) Dim aNewData As String Do While Matcher1.Find aNewData = aNewData & Matcher1.Match Loop input data: ABCDEF01GHIJKL Result: 01G can anyone help me figure out where the error is? Thanks in advance
Hi, I ask for help in solving a problem using the regex feature and I can't figure out where I'm wrong !? with this code I get an incorrect result, because almost all the characters are deleted: Code: Copy Dim Matcher1 As Matcher = Regex.Matcher("\d+[A-Z0-9]", aReader) Dim aNewData As String Do While Matcher1.Find aNewData = aNewData & Matcher1.Match Loop input data: ABCDEF01GHIJKL Result: 01G can anyone help me figure out where the error is? Thanks in advance
Erel B4X founder Staff member Licensed User Longtime User Oct 29, 2020 #2 input data: ABCDEF01GHIJKL Result: 01G Which result do you expect? Upvote 0
Roberto P. Well-Known Member Licensed User Longtime User Oct 29, 2020 #3 in this case the initial string: ABCDEF01GHIJKL i want regex to remove special characters thanks Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Oct 29, 2020 #4 Code: Copy Dim sb As StringBuilder sb.Initialize Dim m As Matcher = Regex.Matcher("[a-zA-Z0-9]+", s) Do While m.Find sb.Append(m.Group(0)) Loop Log(sb.ToString) Upvote 0
Code: Copy Dim sb As StringBuilder sb.Initialize Dim m As Matcher = Regex.Matcher("[a-zA-Z0-9]+", s) Do While m.Find sb.Append(m.Group(0)) Loop Log(sb.ToString)
Roberto P. Well-Known Member Licensed User Longtime User Oct 29, 2020 #5 Erel said: Code: Copy Dim sb As StringBuilder sb.Initialize Dim m As Matcher = Regex.Matcher("[a-zA-Z0-9]+", s) Do While m.Find sb.Append(m.Group(0)) Loop Log(sb.ToString) Click to expand... it's ok, thank you Erel. Upvote 0
Erel said: Code: Copy Dim sb As StringBuilder sb.Initialize Dim m As Matcher = Regex.Matcher("[a-zA-Z0-9]+", s) Do While m.Find sb.Append(m.Group(0)) Loop Log(sb.ToString) Click to expand... it's ok, thank you Erel.