Android Question Regex format error

Roberto P.

Well-Known Member
Licensed User
Longtime User
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:

Regex:
    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
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
in this case the initial string: ABCDEF01GHIJKL

i want regex to remove special characters

thanks
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
B4X:
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)


it's ok, thank you Erel.
 
Upvote 0
Top