Bug? Regex Possible Issue

iCAB

Well-Known Member
Licensed User
Longtime User
Hi There

I believe that regex.split has an issue

try this

B4X:
[INDENT]Dim ScannedText As String = "ABC|DEF|GHI"[/INDENT]
            'Doesn't work
        Dim ScanComponents() As String = Regex.Split("|", ScannedText )

        ScannedText = ScannedText.Replace("|",";")
            'work's
        Dim ScanComponents() As String = Regex.Split(";", ScannedText )
 

DonManfred

Expert
Licensed User
Longtime User
Dim ScannedText As String = "ABC|DEF|GHI"[/INDENT]
'Doesn't work
Dim ScanComponents() As String = Regex.Split("|", ScannedText )
It will work if you do it right

B4X:
    Dim ScannedText As String = "ABC|DEF|GHI"  
    Dim ScanComponents() As String = Regex.Split("\|", ScannedText )
    Log(ScanComponents.Length)

| is a special character and needs to be escaped.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…