What regular expression engine does XCode's Find Navigator use

282 views Asked by At

The documentation from Apple, Google searches, and StackOverflow is non-existent with regard to what RegEx engine XCode's Find Navigator uses, making it very difficult to write expressions. For example, I tried to do a negative lookbehind, and it doesn't work. Does anyone know where the hidden documentation lies?

1

There are 1 answers

0
Ben Lachman On BEST ANSWER

Quick Answer: The ICU Engine. (This is the same engine that is used for NSRegularExpression as well).

Longer version:

The main difference between PCRE and ICU, the two leading regex engines, is PCRE's support for recursion within it's expressions. A simple example of this would be:

\w{3}\d{3}(?R)?

which matches aaa111bbb222 fully. However, entering this into an Xcode (7.1.1) regex find field yields this alert:

Find Failure: not a valid regular expression.

This leads us to believe that Xcode is using the ICU engine to power it's search and replace features. This make sense since Xcode is likely built either on top of NSRegularExpression or the underlying libicucore.