<p>I've seen a lot of commonality in regex capabilities of different regex-enabled tools/languages (e.g. perl, sed, java, vim, etc), but I've also many differences.</p>

<p>Is there a <em>standard</em> subset of regex capabilities that all regex-enabled tools/languages will support? How do regex capabilities vary between tools/languages?</p>

[{'answer_id': 30032, 'author': 'kokos', 'author_id': 1065, 'author_profile': 'https://Stackoverflow.com/users/1065', 'pm_score': 4, 'selected': False, 'text': '<p><a href="http://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines" rel="noreferrer">http://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines</a><br>\nEven more detailed: <a href="http://www.regular-expressions.info/refflavors.html" rel="noreferrer">http://www.regular-expressions.info/refflavors.html</a></p>\n'}, {'answer_id': 30034, 'author': 'Jeff Atwood', 'author_id': 1, 'author_profile': 'https://Stackoverflow.com/users/1', 'pm_score': 5, 'selected': True, 'text': '<p>Compare Regular Expression Flavors</p>\n\n<p><a href="http://www.regular-expressions.info/refflavors.html" rel="noreferrer">http://www.regular-expressions.info/refflavors.html</a></p>\n'}, {'answer_id': 30054, 'author': 'Rob Wells', 'author_id': 2974, 'author_profile': 'https://Stackoverflow.com/users/2974', 'pm_score': 1, 'selected': False, 'text': '<p>If you took the grep regexp grammar, not the egrep one, or the sed regexp grammar and used that you should be using a safe subset across many platforms and tools.</p>\n\n<p>About the only thing that may bite you then is when you go shift between regexp implementations using Finite State Automatons (FSA) and ones using backtracking, e.g. quantifier implementations will vary from grep to Perl.</p>\n\n<p>FSA based implementations will find longest match starting at the first possible position. Backtracking ones will find the left-biased first match, starting at the first possible position. That is, it will try each branch in the order in the pattern until a match is found.</p>\n\n<p>Consider the string <code>"xyxyxyzz"</code>, and the pattern <code>"(xy)*(xyz)?"</code>. FSA based engines will match the longest possible substring, <code>"xyxyxyz"</code>. Back-tracking based engines will match the left-biased first substring, <code>"xyxyxy"</code>.</p>\n'}, {'answer_id': 30057, 'author': 'Joseph Pecoraro', 'author_id': 792, 'author_profile': 'https://Stackoverflow.com/users/792', 'pm_score': 1, 'selected': False, 'text': '<p>Most regular expression tools/languages support these <a href="http://www.regular-expressions.info/reference.html" rel="nofollow noreferrer">basic capabilities</a>:</p>\n\n<ol>\n<li>Character Classes/Sets and their Negation - []</li>\n<li>Anchors - ^$</li>\n<li>Alternation - |</li>\n<li>Quantifiers - ?+*{n,m}</li>\n<li>Metacharacters - \\w, \\s, \\d, ...</li>\n<li>Backreferences - \\1, \\2, ...</li>\n<li>Dot - .</li>\n<li>Simple modifiers like /g and /i for global and ignore case</li>\n<li>Escaping Characters</li>\n</ol>\n\n<p>More advanced tools/languages support:</p>\n\n<ol>\n<li>Lookaheads and behinds</li>\n<li>POSIX character classes</li>\n<li>Word boundaries</li>\n<li>Inline Switches like allowing case insensitivity for only a small section of the regex</li>\n<li>Modifiers like /x to allow extra formatting and comments, /m for multiline</li>\n<li>Named Captures</li>\n<li>Unicode</li>\n</ol>\n'}, {'answer_id': 30064, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>There's no standard engine. However, the POSIX Extended Regular Expression format is a valid subset of most engines and is probably as close as you'll get to a standardised subset.</p>\n"}, {'answer_id': 877827, 'author': 'Jonas Kölker', 'author_id': 58668, 'author_profile': 'https://Stackoverflow.com/users/58668', 'pm_score': 0, 'selected': False, 'text': '<p>See emacs\'s regular expression syntax: <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexps.html#Regexps" rel="nofollow noreferrer">http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexps.html#Regexps</a>.</p>\n\n<p>I recall reading that emacs\'s syntax is set in stone (for backwards compatibility reasons), so if you want to be compatible with <em>everything</em>, make everything compatible with this.  Some tools might support it, others might not.</p>\n\n<p>While you have a worthy goal, I think it\'ll be exceedingly difficult to reach, and I\'ve also found emacs\'s regexps a pain to work with.  Maybe 99% of everything is good enough if it makes you happier and more productive?</p>\n'}]
['https://Stackoverflow.com/questions/30026', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2045/']