Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

usage of ...Pattern.compile()

Tags:

java

regex

Using java.util.regex.Pattern.compile() you can specify a pattern as parameter. But how can you specify flags like case-insensitive and ignore whitespaces as well?

like image 619
Raffael Avatar asked Jul 13 '26 21:07

Raffael


2 Answers

Use the overload that accepts flags.

like image 82
Konrad Rudolph Avatar answered Jul 15 '26 09:07

Konrad Rudolph


You can use the Pattern.compile(String regex, int flags) method that takes flags as well, or you can put them in your Pattern itself:

Eg.

Pattern.compile("(?i)a");
like image 23
wjans Avatar answered Jul 15 '26 09:07

wjans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!