Android Question split a string based on a defined character

gz7tnn

Member
Licensed User
I am unable to find anything that helps me here.
What I want to do is split a string into separate components, where the separator is (eg) ';'
The original string will have 3 segments, however one of those will contain at least 2 or more words.
Example 1> N172635;Long Handled Hammer;1234
Example 2> Misc999;short stubby hammer with steel handle;989h6

I have looked at regex but as the middle segment of the input string will differ each time I have been unable to create a matching pattern via that method.

Any suggestions as to how I can extract the 3 separate components would be appreciated.
 

Eumel

Active Member
Licensed User
With Regex.Split it works..
Which error you get ?


B4X:
    Dim mystring As String = "N172635;Long Handled Hammer;1234"
   
    For Each mystrings As String In Regex.split(";",mystring)
        Log(mystrings)
    Next
 

gz7tnn

Member
Licensed User
Just what I needed. My approach only retrieved the word just before each of the ';'
Much appreciated
 
Top