0

I am looking for something very similar to this, only that I want all matches and not just the first one. In javascript, you can add a 'global' modifier in order to get a list of all matches, is something similar possible in java?

Community
  • 1
  • 1
Arne
  • 17,706
  • 5
  • 83
  • 99
  • Since you do not provide a sample regex and input, it is unsure what you ask; anyway, note that a `Matcher` can match more than once; so, if you have instantiated a `Matcher`, you can do `while (m.find()) /* do something */` – fge Oct 25 '14 at 19:52

1 Answers1

1

Yes, use while instead of an if statement to iterate through the match results.

while (m.find()) {
  ...
}
hwnd
  • 69,796
  • 4
  • 95
  • 132