java.util.regex.Pattern matching the beginning of a String

Posted by Pierre on Stack Overflow See other posts from Stack Overflow or by Pierre
Published on 2010-03-26T21:06:57Z Indexed on 2010/03/26 21:13 UTC
Read the original article Hit count: 582

Filed under:
|
|

Hi all,

Is it possible to know if a stream/string contains an input that could match a regular expression.

For example

 String input="AA";
 Pattern pat=Pattern.compile("AAAAAB");
 Matcher matcher=pat.matcher(input);
 //<-- something here returning true ?

or

 String input="BB";
 Pattern pat=Pattern.compile("AAAAAB");
 Matcher matcher=pat.matcher(input);
 //<-- something here returning false ?

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about regex