Objective-C Library For Easier String Formatting/Masking Using Regular Expressions

I’ve mentioned some libraries for making it easier to perform string validation such as PMValidation and here’s a library from Flavio Caetano that allows you to easily mask and format your NSString data called NSStringMask.

Formatting is done using a regular expression that you can supply directly to the library or you can supply a NSRegularExpression.  You can also supply placeholder data to fill in any empty spaces.

As the readme explains:

suppose you have the string 12345678 and want to format it as a Social Security Number (which regex pattern is \d{3}-\d{2}-\d{3}). With NSStringMask, all you have to do is [NSStringMask maskString:@”12345678″ withPattern:@”(\\d{3})-(\\d{2})-(\\d{3})”] and the result will be “123-45-678“.

You can find NSStringMask on Github here.

A handy library to have around if you find yourself needing to do some string formatting.

FacebookTwitterDiggStumbleUponGoogle Plus

Original article: Objective-C Library For Easier String Formatting/Masking Using Regular Expressions

©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *