开发者

Regular Expressions in Objective-C and Core Data

Is there a guide to using regular expressions in objective c? Specifically what to type into the "Reg. Ex." field in a core data property?

In particular, how to limit input 开发者_如何学编程to a set amount of numbers/letters only, and for UK Post Codes?

Thanks!


According to the Apple documentation, the NSPredicate regex support implements the ICU package, so check their pages for documentation:

ICU Regex Documentation

For example, a regular expression of [0-9a-zA-Z]{5} could be used match on exactly 5 numbers or letters. (So would the shorter form of [\w\d]{5} though that also permits a few other characters)


RegexKit Lite is a wrapper for the ICU regex library which adds a couple of methods to NSString that makes working with ICU a lot easier.

It also includes a short reference for the ICU regex syntax. For tutorials and a more complete reference I recommend regular-expressions.info, which is really handy whenever I write regular expressions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜