Welcome to the documentation for the NSRegexNamedCaptureGroup CocoaPod.
What is NSRegexNamedCaptureGroup?
NSRegexNamedCaptureGroup is a lightweight CocoaPod that provides an easy-to-use way to extract named capture groups from regular expressions in Objective-C and Swift.
Installation
To install NSRegexNamedCaptureGroup, simply add the following line to your Podfile:
pod 'NSRegexNamedCaptureGroup'
Then run pod install
in Terminal and open your project using the newly created .xcworkspace
file.
Usage
To use NSRegexNamedCaptureGroup, follow these steps:
- Create an instance of
NSRegexNamedCaptureGroup
with the required regular expression pattern. - Use the
captureGroupWithName:
method to retrieve the value of a specific named capture group.
Here’s a code example:
// Import the library
#import <NSRegexNamedCaptureGroup/NSRegexNamedCaptureGroup.h>
// Create an instance with the regular expression pattern
NSRegexNamedCaptureGroup *captureGroup = [[NSRegexNamedCaptureGroup alloc] initWithPattern:@"Hello (\\w+)! My name is (?<name>\\w+)." options:0];
// Retrieve the value of the named capture group
NSString *name = [captureGroup captureGroupWithName:@"name"];
NSLog(@"Hello, %@", name);
Contributing
If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request on the GitHub repository.
License
The NSRegexNamedCaptureGroup CocoaPod is available under the MIT license. See the LICENSE file for more info.