Java regex return after first match
Posted
by
user216915
on Stack Overflow
See other posts from Stack Overflow
or by user216915
Published on 2011-01-09T04:44:06Z
Indexed on
2011/01/09
4:53 UTC
Read the original article
Hit count: 385
hi
how do i return after the first match of regular expression? (does the Matcher.find() method do that? )
say I have a string "abcdefgeee". I want to ask the regex engine stop finding immediately after it finds the first match of "e" for example. I am writing a method to return true/false if the pattern is found and i don't want to find the whole string for "e". (I am looking for a regex solution )
thanks
© Stack Overflow or respective owner