by chimeracoder · 13y ago · 0 comments
Go uses RE2, not PCRE (which Perl uses, obviously) for regular expressions: https://code.google.com/p/re2/. There is also a third-party PCRE library for Go somewhere, though the standard library uses RE2.
One of the advantages of RE2 is that it guarantees that the regular expression runs in linear time (in the length of the input), unlike backtracking-engines like PCRE (which are provably undecidable, like the halting problem).
However, aside from not supporting backtraces, it also can be slower on certain kinds of regexes and inputs.
As always, the best (only?) way to know which approach is better is to test (profile) - which, I agree, is a piece of cake in Go.
Incidentally, one of the reasons that PCRE is faster is that it uses a JIT in newer versions.