Examples Given the string foobarbarfoo: bar(?=bar) finds the 1st bar ("bar" which has "bar" after it) bar(?!bar) finds the 2nd bar ("bar" which does not have "bar" after it) (?<=foo)bar finds the 1st bar ("bar" which has "foo" before it) (?) An atomic group exits a group and throws away alternative patterns after the first matched pattern inside the group (backtracking is disabled). (?>foo|foot)s applied to foots will match its 1st alternative foo, then fail as s does not immediately follow, and stop as backtracking is disabled A non-atomic group will allow backtracking; if subsequent matching ahead fails, it will backtrack and use alternative patterns until a match for the entire expression is found or all possibilities are exhausted. (foo|foot)s applied to foots will: match its 1st alternative foo, then fail as s does not immediately follow in foots, and backtrack to its 2nd alternative; match its 2nd alternative foot, then succeed as s immediately follows in foots, and stop. Some resources http://www.regular-expressions.info/lookaround.html http://www.rexegg.com/regex-lookarounds.html SRC: https://stackoverflow.com/questions/2973436/regex-lookahead-lookbehind-and-atomic-groups