<commit_before># Objective-C RegEx Categories

<img title="Make Regular Expressions Easier in Objective-C" alt="Make Regular Expressions Easier in Objective-C" src="https://raw.github.com/bendytree/Objective-C-RegEx-Categories/master/TestProject/Objective-C-Regex-Categories/Images/icon.png" align="right" width="250" height="250" />

 - [Introduction](#introduction)
 - [Getting Started](#gettingstarted)
   - [Cocoa Pods](#gettingstarted-cocoapods)
   - [Download](#gettingstarted-download)
   - [Swift Support](#gettingstarted-swift)
 - [Quick Examples](#examples)
 - [Documentation](#documentation)
   - [Macros](#macros)
   - [Creation](#creation)
   - [Test If Match](#ismatch)
   - [Index Of Match](#indexof)
   - [Split](#split)
   - [First Match](#firstmatch)
   - [Matches](#matches)
   - [Replace](#replace)
   - [RxMatch Objects](#rxmatch)
 - [Support](#support)
 - [Licensing](#licensing)
 - [Testing](#testing)
 - [Alternatives](#alternatives)
 - [Who Uses It](#whousesit)


<a name="introduction"/>
## Introduction

This project makes regular expressions easy in Objective-C.

As of iOS 4 (and OSX 10.7), [`NSRegularExpression`](https://developer.apple.com/library/Mac/DOCUMENTATION/Foundation/Reference/NSRegularExpression_Class/Reference/Reference.html) is built-in to [Foundation.framework](https://developer.apple.com/library/Mac/DOCUMENTATION/Cocoa/Reference/Foundation/ObjC_classic/_index.html#//apple_ref/doc/uid/20001091). The syntax is somewhat cumbersome and it leaves much of the work to you, so this library creates categories and macros to simplify usage of `NSRegularExpression`. 

Here is an example where four lines of code become one:

```objc
// Without this library
NSString* string = @"I have 2 dogs.";
NSRegularExpression *regex = [NSRegularExpression regular ExpressionWithPattern:@"\\d+" options:NSRegularExpressionCaseInsensitive error:&error];
NSTextCheckingResult *match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])];
BOOL isMatch = match != nil;

// With this library<commit_msg>Added Swift support to description<commit_after># Objective-C RegEx Categories

<img title="Make Regular Expressions Easier in Objective-C" alt="Make Regular Expressions Easier in Objective-C" src="https://raw.github.com/bendytree/Objective-C-RegEx-Categories/master/TestProject/Objective-C-Regex-Categories/Images/icon.png" align="right" width="250" height="250" />

 - [Introduction](#introduction)
 - [Getting Started](#gettingstarted)
   - [Cocoa Pods](#gettingstarted-cocoapods)
   - [Download](#gettingstarted-download)
   - [Swift Support](#gettingstarted-swift)
 - [Quick Examples](#examples)
 - [Documentation](#documentation)
   - [Macros](#macros)
   - [Creation](#creation)
   - [Test If Match](#ismatch)
   - [Index Of Match](#indexof)
   - [Split](#split)
   - [First Match](#firstmatch)
   - [Matches](#matches)
   - [Replace](#replace)
   - [RxMatch Objects](#rxmatch)
 - [Support](#support)
 - [Licensing](#licensing)
 - [Testing](#testing)
 - [Alternatives](#alternatives)
 - [Who Uses It](#whousesit)


<a name="introduction"/>
## Introduction

This project simplifies regular expressions in Objective-C and Swift.

As of iOS 4 (and OSX 10.7), [`NSRegularExpression`](https://developer.apple.com/library/Mac/DOCUMENTATION/Foundation/Reference/NSRegularExpression_Class/Reference/Reference.html) is built-in to [Foundation.framework](https://developer.apple.com/library/Mac/DOCUMENTATION/Cocoa/Reference/Foundation/ObjC_classic/_index.html#//apple_ref/doc/uid/20001091). The syntax is somewhat cumbersome and it leaves much of the work to you, so this library creates categories and macros to simplify usage of `NSRegularExpression`. 

Here is an example where four lines of code become one:

```objc
// Without this library
NSString* string = @"I have 2 dogs.";
NSRegularExpression *regex = [NSRegularExpression regular ExpressionWithPattern:@"\\d+" options:NSRegularExpressionCaseInsensitive error:&error];
NSTextCheckingResult *match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])];
BOOL isMatch = match != nil;

// With this library
{'fraction_non_alphanumeric': 0.13882863340563992, 'fraction_numerical': 0.01012292118582791, 'mean_word_length': 5.384615384615385, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2668943', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1184, 'n_words': 296}