How can I read the first substring that matches my pattern?
I have tried with
while (m.find()) {
URL=(m.group(1));
}
With 1 in the group call the app crashes, and if I put nothing in it I get only the last match, I have to read the first matched string, how can I do?
It give me an error about regex, but it’s strange because without the 1 in between the () the app works good and don’t give me any error about my regex…
How does it crash? What is the regex?
group(0)is the whole match andgroup(i), i >0will give you the captures in the regex if any. Alsowhile(m.find())processes the string until any matches left. So callfind()only once if you need the first match.