What is the Java RegEx equivalent to the SQL LIKE clause of "%A%B%"?
Pretty basic question, I'm just learning the Java Regex flavor.
I think this is it pattern wise: .*A.*B.*
I'll edit and add more for specific java calls.
EDIT #1:
//simplest match
"".matches( ".*A.*B.*" );
String foo = "";
foo.matches( ".*A.*B.*" );
EDIT #2: From the API docs:
Pattern p = Pattern.compile(".*A.*B.*");
Matcher m = p.matcher("your-string-here");
boolean b = m.matches();
Also, I would take a look at RegexBuddy, its not free but it does have means to generate snippets for many languages, test & parse regex's, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With