I know you thought you'd never hear these words from me, but: this is probably better done with regex :-/
Nonetheless... try this:
B4X:
Dim L As List
L.Initialize
Dim S As String = "Today #I# got to #experiment# #with# reef. I #needed# this to try #and# see if #I# can #wrap# it with #BANano#.png"
Dim OpenHashAt As Int = -1
For I = 0 To S.Length - 1
If S.CharAt(I) = "#" Then
If OpenHashAt = -1 Then 'if not currently inside a hash field
OpenHashAt = I
Else 'currently inside a hash field
L.Add(S.SubString2(OpenHashAt + 1, I))
OpenHashAt = -1 'now outside of hash field, get ready for next one
End If
End If
Next I
Well ... with the regEx stuff that you don't want. Lol.
B4X:
Dim text As String ="Today #I# got to #experiment# #with# reef. I #needed# this to try #and# see if #I# can #wrap# it with #BANano#.png"
Dim pattern As String = "#(.*?)#"
Dim Matcher1 As Matcher
Dim l As List : l.initialize
Matcher1 = Regex.Matcher(pattern, text)
Do While Matcher1.Find
Log("Found: " & Matcher1.Group(1))
l.Add(Matcher1.Group(1))
Loop