10

I'm confused about the regex libraries that are available in the iPhone SDK. For example RegexLite looks like it needs a dynamic link, and from what I understand, this is not possible for the SDK on the iPhone.

I want a RegEx library for data validation... which one is the best available?

BastiBen
  • 19,679
  • 11
  • 56
  • 86
mamcx
  • 15,916
  • 26
  • 101
  • 189

6 Answers6

12

Just want to add here that iOS 4 now has NSRegularExpression.

Marc Rochkind
  • 3,678
  • 3
  • 30
  • 38
  • And so does MacOS 10.7 (Lion) now. However, as I develop for the Mac App Store, I support 10.6 and 10.7, so I can't use this facility. – Marc Rochkind Sep 26 '11 at 13:29
7

John Englehart (regexkitlite developer) has posted to cocoa-dev saying that apps are being rejected for using it. http://lists.apple.com/archives/Cocoa-dev/2010/Jun/msg00564.html

(Apologies for this purporting to be an "answer", it would be a reply to Kendall Helmstetter Gelner if only I had 49 more reputation points).

bonaldi
  • 992
  • 1
  • 8
  • 11
  • thanks for passing this info on. – Ross Jun 21 '10 at 15:53
  • Interesting, the NDA is lifted now so does anyone have any clearer description? The only speculation I could find was they considered the ICU stuff to be private APIs... – Kendall Helmstetter Gelner Jun 23 '10 at 00:14
  • It looks like the issue is probably resolved. See this followup from the developer. http://www.cocoabuilder.com/archive/cocoa/288966-update-applications-using-regexkitlite-no-longer-being-accepted-at-the-appstore.html#289872 – Jacques Aug 14 '10 at 22:43
4

RegexKitLite is available and works properly on iPhone either included from source as part of your Xcode project or by linking in a static library (which the ToS of the SDK do permit).

wisequark
  • 3,288
  • 20
  • 12
3

Using RegexKitLite requires dragging only a source and header file into your project, and works really well - it offers most of the features you'd want from a regex library. It's basically just a very thin wrapper around an underlying framework that's already there.

Make sure the source type for header and .m file is "sourcecode.c.objc" after you add them to the project (Use "Get Info" on a given source file and look at the "General" tab).

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
  • Reports are coming that iOS4 apps using RegexKitLite are being rejected supposedly due to violation of §3.3.1 – glebd Jun 15 '10 at 01:13
  • This seems very unlikely given that it's a thin wrapper around the RegEx support built into the existing iPhone libraries. It would be rather like banning an app that used a UIWebView... Do you have a link with someone noting a rejection on those grounds? Google found nothing except speculation. You may possibly be confused by someone who used RegexKitLite to parse a custom language script. But for something like that you could probably get approval (note that 3.3.1 has been revised to allow you to seek an exception). – Kendall Helmstetter Gelner Jun 15 '10 at 03:45
  • Link further down on the page on @bonaldi's answer – Ross Jun 22 '10 at 09:21
2

RegexKitLite uses the regular expression engine provided by the libicucore.A.dylib library. However Apple does not officially support linking directly against this library. See this post to the Xcode-users mailing list for details. However despite this there are many iPhone applications available on the App Store than make use of RegexKitLite, so it's unlikely (but not impossible) that Apple will reject your application for making use of it.

Alasdair Allan
  • 2,134
  • 2
  • 18
  • 18
0

This is a nice lightweight alternative to RegexKitLite: https://github.com/bendytree/Objective-C-RegEx-Categories

whyp
  • 603
  • 5
  • 14