views:

295

answers:

3

Are Python and JavaScript regular expression syntax identical?

If not, then:

  1. What are the important differences between them
  2. Is there a python library that "implements" JavaScript regexps?
+11  A: 

There is a comparison table here:

Regex Flavor Comparison

EBGreen
+1: Wow, what a lot of stuff.
S.Lott
Thanks! My attempts at googling the answer failed.Now, I guess the follow up question is: "Is there a python library that 'implements' javascript regexps?"
Dave Peck
I don't know of one. What is the root reason for wanting one?
EBGreen
@EBGreen: I'd like a Python library compatible with EMCA regex because I want consistency between a regex search in Python on the back-end and a Javascript one on the front-end.
Brian M. Hunt
A: 

Part 1
They are different; One difference is Python supports Unicode and Javascript doesn't.

Part 2
Read Mastering Regular Expressions. It gives information on how to identify the back-end engines (DFA vs NFA vs Hybrid) that a regex flavour uses. It gives tons of information on the different regex flavours out there.

There is way too much information to convey on a single SO answer, so you're better off having a solid piece of reference material on the subject.

(Yes, I'm from Canada... how could you tell, eh?)

Gavin Miller