Joshua Joshua - 1 year ago 84
Objective-C Question

Search through NSString using Regular Expression

How might I go about searching/enumerating through an

using a regular expression?

A regular expression such as:

Answer Source

You need to use NSRegularExpression class.

Example inspired in the documentation:

NSString *yourString = @"";
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression         
[regex enumerateMatchesInString:yourString options:0 range:NSMakeRange(0, [yourString length]) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop){
    // your code to handle matches here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download