Java’s Pattern class and regular expressions
18 March 2012
One of the easiest things to get tripped up on is the syntax for creating regular expressions (regex) in Java using the Pattern class. The tl;dr version of how to do things is that you must use double-backslashes in the regular expression Strings you use to create a Pattern object; so something like \b
would have to be written as "\\b"
. Read on for a more thorough explanation.