RegexKit Framework Reference
Regular Expressions for
Objective-C
RegexKit Programming Guide
Introduction
Highlights
Prerequisites
Documentation Overview
Regular Expressions
The Basics
Extracting Part of a Match
Capture Subpatterns
Named Capture Subpatterns
Nested Capture Subpatterns
It Only Gets More Complicated from Here
The RegexKit Classes
RKRegex
RKCache
RKEnumerator
Foundation Extensions
NSString Additions
Capture Extraction
Capture Type Conversion
Determining if a String is Matched by a Regular Expression
Finding the Range of a Match
Creating a New String Using the Results of a Match
Search and Replace
Enumerating all the Matches in a String by a Regular Expression
DTrace Probe Points in RegexKit
RegexKit Provider DTrace Probe Points
Performance Notification Related Probes
Regular Expression Related Probes
Cache Related Probes
Multithreaded Locks Related Probes
Accessing Probes From the Shell
Accessing Probes With Instruments.app
Adding the RegexKit.framework to your Project
Outline of Required Steps
Linking to the Framework
Copying the Framework to your Applications Bundle
Importing the RegexKit.h Header
Finished
License Information
RegexKit Implementation Topics
PCRE Version and Feature Support
PCRE Versions Supported
Features Supported
Features Not Supported
Multithreading Safety
Thread Local Data
Atomic Primitives
Single threaded vs. Multithreaded
GNUstep Specifics
Building the RegexKit.framework with Xcode
GNUstep
Implementation Details
OpenStep Foundation vs. Core Foundation
Framework Dependencies
License Information
Release Information
Release History
Subversion Repository
Release Notes
Release 0.6.0 Beta
Release 0.5.0 Beta
Release 0.4.0 Beta
Release 0.3.1 Beta
Release 0.3.0 Beta
Release 0.2.0 Beta
Release Alpha
Change Log
Release 0.6.0 Beta
Release 0.5.0 Beta
Release 0.4.0 Beta
Release 0.3.1 Beta
Release 0.3.0 Beta
Release 0.2.0 Beta
Release Alpha
Version Number Information
User Contributions
License Information
Framework Classes
RKRegex
PCRE Library Information
+ PCREBuildConfig
+ PCREMajorVersion
+ PCREMinorVersion
+ PCREVersionString
Regular Expression Cache
+ regexCache
Creating Regular Expressions
+ isValidRegexString:options:
+ regexWithRegexString:library:options:error:
+ regexWithRegexString:options:
- initWithRegexString:library:options:error:
- initWithRegexString:options:
Instantiated Regular Expression Information
- captureCount
- compileOption
- regexString
Named Capture Information
- captureIndexForCaptureName:
- captureIndexForCaptureName:inMatchedRanges:
- captureIndexForCaptureName:inMatchedRanges:error:
- captureNameArray
- captureNameForCaptureIndex:
- isValidCaptureName:
Matching Regular Expressions
- getRanges:withCharacters:length:inRange:options:
- matchesCharacters:length:inRange:options:
- rangeForCharacters:length:inRange:captureIndex:options:
- rangesForCharacters:length:inRange:options:
RKCache
Creating Caches
- initWithDescription:
Adding, Retrieving, and Removing Objects from the Cache
- addObjectToCache:
- addObjectToCache:withHash:
- objectForHash:description:
- objectForHash:description:autorelease:
- removeObjectFromCache:
- removeObjectWithHash:
Cache Information
- cacheCount
- cacheSet
- description
- setDescription:
- status
Cache Maintenance
- clearCache
- isCacheEnabled
- setCacheEnabled:
RKEnumerator
Advancing to the Next Match
- nextObject
- nextRange
- nextRangeForCapture:
- nextRangeForCaptureName:
- nextRanges
Capture Extraction and Conversion
- getCapturesWithReferences:, ...
Current Match Information
- currentRange
- currentRangeForCapture:
- currentRangeForCaptureName:
- currentRanges
Creating Regular Expression Enumerators
+ enumeratorWithRegex:string:
+ enumeratorWithRegex:string:inRange:
+ enumeratorWithRegex:string:inRange:error:
- initWithRegex:string:
- initWithRegex:string:inRange:
- initWithRegex:string:inRange:error:
Instantiated Enumerator Information
- regex
- string
Creating Temporary Strings from the Current Enumerated Match
- stringWithReferenceFormat:, ...
- stringWithReferenceFormat:arguments:
- stringWithReferenceString:
Foundation Additions
NSArray
Deriving New Arrays
- arrayByMatchingObjectsWithRegex:
- arrayByMatchingObjectsWithRegex:inRange:
Querying an Array
- containsObjectMatchingRegex:
- containsObjectMatchingRegex:inRange:
- countOfObjectsMatchingRegex:
- countOfObjectsMatchingRegex:inRange:
- indexOfObjectMatchingRegex:
- indexOfObjectMatchingRegex:inRange:
- indexSetOfObjectsMatchingRegex:
- indexSetOfObjectsMatchingRegex:inRange:
NSData
Accessing Data
- subdataByMatching:
- subdataByMatching:inRange:
Determining the Range of a Match
- rangeOfRegex:
- rangeOfRegex:inRange:capture:
- rangesOfRegex:
- rangesOfRegex:inRange:
Testing Data
- isMatchedByRegex:
- isMatchedByRegex:inRange:
NSDictionary
Deriving New Dictionaries
- dictionaryByMatchingKeysWithRegex:
- dictionaryByMatchingObjectsWithRegex:
Accessing Keys and Values
- keysForObjectsMatchingRegex:
- keysMatchingRegex:
- objectsForKeysMatchingRegex:
- objectsMatchingRegex:
Querying a Dictionary
- containsKeyMatchingRegex:
- containsObjectMatchingRegex:
NSObject
Identifying and Comparing Objects
- isMatchedByRegex:
Identifying Matches in an Array
- anyMatchingRegexInArray:
- anyMatchingRegexInArray:library:options:error:
- firstMatchingRegexInArray:
- firstMatchingRegexInArray:library:options:error:
- isMatchedByAnyRegexInArray:
- isMatchedByAnyRegexInArray:library:options:error:
Identifying Matches in a Set
- anyMatchingRegexInSet:
- anyMatchingRegexInSet:library:options:error:
- isMatchedByAnyRegexInSet:
- isMatchedByAnyRegexInSet:library:options:error:
NSSet
Deriving New Sets
- setByMatchingObjectsWithRegex:
Querying a Set
- anyObjectMatchingRegex:
- containsObjectMatchingRegex:
- countOfObjectsMatchingRegex:
NSString
Capture Extraction and Conversion
- getCapturesWithRegex:inRange:references:, ...
- getCapturesWithRegexAndReferences:, ...
Determining the Range of a Match
- rangeOfRegex:
- rangeOfRegex:inRange:capture:
- rangesOfRegex:
- rangesOfRegex:inRange:
Enumerating Matches
- matchEnumeratorWithRegex:
- matchEnumeratorWithRegex:inRange:
Identifying Matches
- isMatchedByRegex:
- isMatchedByRegex:inRange:
Creating Temporary Strings from Match Results
- stringByMatching:inRange:withReferenceFormat:, ...
- stringByMatching:inRange:withReferenceString:
- stringByMatching:withReferenceFormat:, ...
- stringByMatching:withReferenceString:
Search and Replace
- stringByMatching:inRange:replace:withReferenceFormat:, ...
- stringByMatching:inRange:replace:withReferenceString:
- stringByMatching:replace:withReferenceFormat:, ...
- stringByMatching:replace:withReferenceString:
NSMutableArray
Adding Objects
- addObjectsFromArray:matchingRegex:
Removing Objects
- removeObjectsMatchingRegex:
- removeObjectsMatchingRegex:inRange:
NSMutableDictionary
Adding Entries
- addEntriesFromDictionary:withKeysMatchingRegex:
- addEntriesFromDictionary:withObjectsMatchingRegex:
Removing Entries
- removeObjectsForKeysMatchingRegex:
- removeObjectsMatchingRegex:
NSMutableSet
Removing Objects
- removeObjectsMatchingRegex:
Adding Objects
- addObjectsFromArray:matchingRegex:
- addObjectsFromSet:matchingRegex:
NSMutableString
Search and Replace
- match:replace:withString:
Functions
Utility Functions
RKArrayFromBuildConfig
RKArrayFromCompileOption
RKArrayFromMatchOption
RKStringFromCompileErrorCode
RKStringFromMatchErrorCode
RKStringFromNewlineOption
Unicode Character Index Conversions
RKConvertUTF16ToUTF8RangeForString
RKConvertUTF8ToUTF16RangeForString
DataTypes
RKBuildConfig
RKCompileErrorCode
RKCompileOption
RKMatchErrorCode
RKMatchOption
Constants
Constants
RKReplaceAll
Error Domains
RKRegexErrorDomain
RKRegexPCRELibraryErrorDomain
Error Keys in User Info Dictionaries
RKAbreviatedAttributedRegexStringErrorKey
RKAbreviatedRegexStringErrorKey
RKAbreviatedRegexStringErrorRangeErrorKey
RKArrayIndexErrorKey
RKAttributedRegexStringErrorKey
RKCollectionErrorKey
RKCompileErrorCodeErrorKey
RKCompileErrorCodeStringErrorKey
RKCompileOptionArrayErrorKey
RKCompileOptionArrayStringErrorKey
RKCompileOptionErrorKey
RKObjectErrorKey
RKRegexLibraryErrorKey
RKRegexLibraryErrorStringErrorKey
RKRegexStringErrorKey
RKRegexStringErrorRangeErrorKey
Exceptions
RKRegexCaptureReferenceException
RKRegexSyntaxErrorException
RKRegexUnsupportedException
Preprocessor Macros
ENABLE_DTRACE_INSTRUMENTATION
ENABLE_MACOSX_GARBAGE_COLLECTION
RKInteger
RKIntegerMax
RKIntegerMin
RKREGEX_STATIC_INLINE
RKUInteger
RKUIntegerMax
RK_ATTRIBUTES
RK_C99
RK_EXPECTED
RK_REQUIRES_NIL_TERMINATION
Regular Expression Libraries
RKRegexPCRELibrary
Related Reference
Quick Reference
PCRE Regular Expression Syntax Summary
Quoting
Characters
Character Types
General Category Property Codes for \P and \P
Script Names for \P and \P
Character Classes
Quantifiers
Anchors and Simple Assertions
Match Point Reset
Alternation
Capturing
Atomic Groups
Comment
Option Setting
Lookahead and Lookbehind Assertions
Backreferences
Subroutine References (Possibly Recursive)
Conditional Patterns
Backtracking Control
Newline Conventions
What \R Matches
Callouts
See Also
Regular Expression Syntax
PCRE Regular Expression Details
Newline Conventions
Characters and Metacharacters
Backslash
Circumflex and Dollar
Full Stop (Period, Dot)
Matching a Single Byte
Square Brackets and Character Classes
POSIX Character Classes
Vertical Bar
Internal Option Setting
Subpatterns
Duplicate Subpattern Numbers
Named Subpatterns
Repetition
Atomic Grouping and Possessive Quantifiers
Back References
Assertions
Conditional Subpatterns
Comments
Recursive Patterns
Subpatterns as Subroutines
Callouts
Backtracking Control
See Also
Related Documentation
PCRE Documentation
Introductory Page
Introduction
User Documentation
Limitations
UTF-8 and Unicode Property Support
Information about the Installation Configuration
Synopsis
Description
Options
See Also
PCRE's Native API
PCRE Native API
PCRE API Overview
Newlines
Multithreading
Saving Precompiled Patterns for Later Use
Checking Build-Time Options
Compiling a Pattern
Compilation Error Codes
Studying a Pattern
Locale Support
Information about a Pattern
Obsolete Info Function
Reference Counts
Matching a Pattern: The Traditional Function
Extracting Captured Substrings by Number
Extracting Captured Substrings by Name
Duplicate Subpattern Names
Finding All Possible Matches
Matching a Pattern: The Alternative Function
See Also
Options for Building PCRE
PCRE Build-Time Options
C++ Support
UTF-8 Support
Unicode Character Property Support
Code Value of Newline
What \R Matches
Building Shared and Static Libraries
POSIX malloc Usage
Handling Very Large Patterns
Avoiding Excessive Stack Usage
Limiting PCRE Resource Usage
Creating Character Tables at Build Time
Using EBCDIC Code
Pcregrep Options for Compressed File Support
Pcretest Option for Libreadline Support
See Also
The Callout Facility
PCRE Callouts
Missing Callouts
The Callout Interface
Return Values
Compability with Perl
Differences between PCRE and Perl
The C++ Wrapper for the PCRE Library
Synopsis of C++ Wrapper
Description
Matching Interface
Quoting Metacharacters
Partial Matches
UTF-8 and the Matching Interface
Passing Modifiers to the Regular Expression Engine
Scanning Text Incrementally
Parsing Hex/Octal/C-Radix Numbers
Replacing Parts of Strings
The pcregrep Command
Synopsis
Description
Support for Compressed Files
Options
Environment Variables
Newlines
Options Compatibility
Options with Data
Matching Errors
Diagnostics
See Also
Discussion of the Two Matching Algorithms
PCRE Matching Algorithms
Regular Expressions as Trees
The Standard Matching Algorithm
The Alternative Matching Algorithm
Advantages of the Alternative Algorithm
Disadvantages of the Alternative Algorithm
Using PCRE for Partial Matching
Partial Matching in PCRE
Restricted Patterns for pcre_partial
Example of Partial Matching Using pcretest
Multi-Segment Matching with pcre_dfa_exec()
Specification of the Regular Expressions Supported by PCRE
PCRE Regular Expression Details
Newline Conventions
Characters and Metacharacters
Backslash
Circumflex and Dollar
Full Stop (Period, Dot)
Matching a Single Byte
Square Brackets and Character Classes
POSIX Character Classes
Vertical Bar
Internal Option Setting
Subpatterns
Duplicate Subpattern Numbers
Named Subpatterns
Repetition
Atomic Grouping and Possessive Quantifiers
Back References
Assertions
Conditional Subpatterns
Comments
Recursive Patterns
Subpatterns as Subroutines
Callouts
Backtracking Control
See Also
Some Comments on Performance
PCRE Performance
The POSIX API to the PCRE Library
Synopsis of POSIX API
Description
Compiling a Pattern
Matching Newline Characters
Matching a Pattern
Error Messages
Memory Usage
How to Save and Re-Use Compiled Patterns
Saving and Re-Using Precompiled PCRE Patterns
Saving a Compiled Pattern
Re-Using a Precompiled Pattern
Compatibility with Different PCRE Releases
Description of the Sample Program
PCRE Sample Program
Discussion of PCRE's Stack Usage
PCRE Discussion of Stack Usage
Syntax Quick-Reference Summary
PCRE Regular Expression Syntax Summary
Quoting
Characters
Character Types
General Category Property Codes for \P and \P
Script Names for \P and \P
Character Classes
Quantifiers
Anchors and Simple Assertions
Match Point Reset
Alternation
Capturing
Atomic Groups
Comment
Option Setting
Lookahead and Lookbehind Assertions
Backreferences
Subroutine References (Possibly Recursive)
Conditional Patterns
Backtracking Control
Newline Conventions
What \R Matches
Callouts
See Also