This works well, but the split elements do not preserve the case.
B4X:
Dim sentence = "There is NO End to the end of the Covid19" As String 'works
Dim pat As String ="end"
Dim l As List
l.Initialize
Dim m As Matcher
m = Regex.Matcher2(pat, Regex.CASE_INSENSITIVE, sentence) 'Matcher2 not Matcher
Do While m.Find
Log(m.Match)
l.Add(m.Match)
Loop
Log("-----")
sentence=sentence.ToLowercase
pat=pat.ToLowercase
Dim s() As String =Regex.Split(pat,sentence)
For i=0 To s.Length -1
Log(s(i))
Next
Result:
there is no
to the
of the covid19
I like the result to be exactly as below in the sentence. How do we fix the pattern: to achieve the below result
There is NO
to the
of the Covid19