Try this:
Dim regMatch As MatchCollection = Regex.Matches(sttTest, "\S.*?(?=\s{" & LenSpace & ",}|\s*$)")
Regex.Split can be used too.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How can the distance between non-printing text characters be matched and kept to less than 2 characters long using regex?
Dim LenSpace As Integer = 2
Dim sttTest As String = "[A A] [AA BB] [SS UU POPO SS] [GAB]" & vbTab & " [ZZZZ]"
Dim patt As String = "(?<=\S)\s{" & LenSpace & ",}(?=\S)"
Dim regMath As MatchCollection = Regex.Matches(sttTest, patt)
The expected result should contain matches like:
But I see the opposite of what I expected in the output. Expecting an array output of 5 text elements, but I see 4 empty space elements.
Try this:
Dim regMatch As MatchCollection = Regex.Matches(sttTest, "\S.*?(?=\s{" & LenSpace & ",}|\s*$)")
Regex.Split can be used too.