That sounds like a reason to use Regular Expressions. I’m no RegEx expert, but Kem (who I call an expert) did a great webinar on RegEx a couple weeks ago:
dim s as string = "For example I would like to extract all occurrences of text from a string that appears between <h3> and </h3> where the number of occurrences is not predictable and the position of each occurrence is not predictable."
dim v() as string
dim fifi() as string
dim occurrences() as string
v=split(s,"<h3>")
for i as integer = 0 to v.Ubound
if instr(v(i),"</h3>")>0 then
fifi = split(v(i),"</h3>")
occurrences.append(fifi(0))
end if
next
msgbox(occurrences(0))
This will extract all occurrences and place them in the array occurrences(). You got the number of found occurrences as occurrences.ubound.
This short snippet ends with a msgbox that displays the first occurrence in your text :“and”.
dim rx as new RegEx
rx.SearchPattern = "(?Umsi)<h3>(.*)(?=</h3>)</h3>"
dm arr() as string
dim match as RegExMatch = rx.Search( sourceText )
while match <> nil
arr.Append match.SubExpressionString( 1 )
match = rx.Search
wend