REGULAR EXPRESSIONS See "perlre" man page or API Spec doc for java.util.regex.Pattern class. \ retains it "escaping" purpose inside of character classes, therefore "[\\n\\$\\]\\W]" (Java String) doesn't match any back-slashes. You definitely must still escape \\ inside of [], so: /\\/ === /[\\] Char class definitions may use character classes: [\s\S] Dot inside character class means literal ˙.'. For distinctiveness, to match ^ and - characters within a [char class], put the ‐ in first position and ^ in non-first position. TRICKY: Unlike most characters, \ retains its metacharacter behavior inside of character classes, so to match \ literally in a character class you must use \\. As far as I know, only Java supports \Q...\E. $^ can never match! With m option off, ^ must always be at beginning of pattern and $ at end of pattern (and are in fact implied by the match() method). With m option on, in other positions there will always be line-delimiter char(s) between the $ and the ^ which must be matched. Therefore, it's often easier to match line breaks with a literal like \\r?\\n Don't need to delimit $1 to $9. E.g.: replaceFirst("cat(dog)", "$1otherword"); Can't tell from perl or Java docs, but | has very LOW precedence. ^a.*b$|^c.*d$ will match "alpha crab" and "chester mound". OPTIONS: Critical to understand this for either Perl or Java: \s CAN ALWAYS MATCH MULTIPLE LINES! i: case-Insensitive. Duh. s: THERE IS NO s OPTION IN JavaScript. Makes "." match newlines. Only use if your regex contains ".". N.b. THIS HAS NO EFFECT ON \s, JUST ON "."! (aka "dotall") ***s switch does not effect \s class, but dot class! *** I.e. by default dot matches everything EXCEPT line terminators. m: Makes "^" and "$" match line-by-line instead of for entire input. g: THERE IS NO g OPTION IN Java. Only one replacement will ever be performed unless you use an *All* method. In Perl this means to repeat the replacement as many times as possible. N.b.! By default, "^" and "$" match only ONCE for entire input expression. N.b. You do NOT need to use :m to work on multi-line input. N.b. \s ALWAYS matches all whitespace characters. MNEMONIC: Both ":s" and ":m" make the re match MORE TIMES than it would by default. Since \s is never restricted by newlines, it always successfully matches \r and \n. GOTCHA! If you want to match white-space but not across line boundaries, then use [ \t], not \s. Match which portion? Perl "implies no ^ or $ and the pattern will match anywhere within string Javascript /RE/.test(String) implies no ^ or $ and the pattern will match anywhere within string Javascript /RE/.exec(String) implies no ^ or $ PowerShell RE tests imply no ^ or $ TPL matches String implies no ^ or $ HTML5 input pattern matches entire string (implies ^...$). Java .matches() matches entire string (implies ^...$). String.matches, Pattern.matches(), Matcher.matches Java .find() does not Python re.match(pat, str) implies ^... Python re.search(pat, str) implies nothing (looks for substrings) Python re.sub(pat, repl, string, max=0) implies nothing awk top-level patterns, match functions, ~ operator imply no ^ or $ JavaScript has no dotall/s option until ECMAScript 2018. Use [\S\s] in place of . with /s option. \Q,\E JavaScript doesn't support. Python doesn't support. \w = [a-zA-Z] + \d + underscore In Java, the [a-zA-Z] != Character.isLetter(), since [a-zA-Z] includes only ASCII letters whereas Java includes tons of non-ASCII letters. Similarly for the \p (Posix) character classes. Must use the \p{java*} character classes to get beyone US-ASCII. \s with "." is pretty much required if using match() with multi-line input unless the re covers every line of the input. the entire mul ??? Negative lookahead operator (?!X) works like a general negative operator. There is also negative lookbehind (?