views:

84

answers:

1

Since Apple now appears to be rejecting apps that link to libicucore (such as apps that utilize RegexKitLite), what is the best way to get regular expressions with capture group functionality to work from within an iPhone app? Should one statically compile ICU or PCRE (perhaps using the RegexKit PCRE wrapper)?

+1  A: 

See this cocoa-dev post for more information about what caused applications using RegexKitLite to be rejected.

The short answer is it is still possible to use RegexKitLite and not get rejected.

johne
Thank you, this is a great help and I had not seen that response. I've already [built and statically linked PCRE](http://github.com/hadronzoo/build-pcre-iphone) and written a wrapper for it, but I'll consider RegexKitLite for future projects.
hadronzoo
One of the problems with using PCRE is that it can operate only on UTF8 encoded text (assuming you want Unicode, which you probably do). NSStrings, on the other hand, use a UTF-16 as their logical abstraction. This means that "ranges" can not trivially be mixed between the two. For example, the range of a match in PCRE will be the UTF8 byte offsets. For an NSString, the same range of characters would be the UTF-16 character offsets. UTF8 requires 1-~5 bytes per Unicode code point, but UTF-16 uses 16-bit characters which can represent the majority of Unicode in just 1 16-bit unit.
johne
PCRE provides some functions to extract ranges as cstrings and NString has good support for conversion to and from UTF-8. While copying matches is less efficient, I haven't found it to be significant for my application.
hadronzoo