4 ms·
If you've already done the profiling, you're probably already aware of this, but for anybody else: Go uses RE2, not PCRE (which Perl uses, obviously) for regul
by chimeracoder 13y ago
If you've already done the profiling, you're probably already aware of this, but for anybody else:
Go uses RE2, not PCRE (which Perl uses, obviously) for regular expressions: https://code.google.com/p/re2/ 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.
- pcwalton 13y agoPerl doesn't actually use PCRE by default, though it's an option in 5.10. Incidentally, one of the reasons that PCRE is faster is that it uses a JIT in newer versions.