Count the number of times string has been split

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I am using the following code:

B4X:
Dim msg As String
   msg = "123" & CRLF & "456" & CRLF & "789"
Dim strBeforeSplit As String 
   strBeforeSplit=msg
Dim strSplit() As String
   strSplit=Regex.Split(CRLF,strBeforeSplit)

what the code above does is runs through the msg string and splits the string based on a CRLF so, if I log strSplit(0) it would log 123 if I log strSplit(1) it would log 456 etc.

but I need to find out how many CRLF / strSplit(x) there are.

does anyone have any ideas ?
 

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

Thanks for the fast reply..

I ended up getting it working by doing this:
(which is basically what you guys are saying)

B4X:
Dim msg As String
    msg = "123" & CRLF & "456" & CRLF & "789"
Dim strBeforeSplit As String 
    strBeforeSplit=msg
Dim strSplit() As String
    strSplit=Regex.Split(CRLF,strBeforeSplit)

For x = 0 To strSplit.Length - 1 
   Log(strSplit(x))
Next
 
Upvote 0
Top