NSMutableString(MBRegex) Category Reference
Declared in | NSString+MBRegex.h |
---|
Overview
An NSMutableString
class extension that provides regular expression
replacement methods.
To improve performance, these methods utilize the MBRegexCache
when
possible.
For additional information on the workings of regular expressions, see the
Apple documentation for NSRegularExpression
.
Performing regex replacements in a mutable string
– replaceRegexMatches:withTemplate:
Performs a regular expression string replacement on the receiver.
- (NSUInteger)replaceRegexMatches:(nonnull NSString *)pattern withTemplate:(nonnull NSString *)templ
Parameters
pattern |
The regular expression pattern to match. |
---|---|
templ |
The template to use for performing replacements of any matches found in the receiver. |
Return Value
The number of matches performed.
Discussion
If the receiver contains any matches for the specified regular expression pattern, the receiver will be modified so that those matches are replaced according to the template provided.
Declared In
NSString+MBRegex.h
– replaceRegexMatches:withTemplate:options:
Performs a regular expression string replacement on the receiver.
- (NSUInteger)replaceRegexMatches:(nonnull NSString *)pattern withTemplate:(nonnull NSString *)templ options:(NSRegularExpressionOptions)options
Parameters
pattern |
The regular expression pattern to match. |
---|---|
templ |
The template to use for performing replacements of any matches found in the receiver. |
options |
The options that govern the behavior of the returned regular expression. |
Return Value
The number of matches performed.
Discussion
If the receiver contains any matches for the specified regular expression pattern, the receiver will be modified so that those matches are replaced according to the template provided.
Declared In
NSString+MBRegex.h
– replaceRegexMatches:withTemplate:options:range:
Performs a regular expression string replacement on the receiver.
- (NSUInteger)replaceRegexMatches:(nonnull NSString *)pattern withTemplate:(nonnull NSString *)templ options:(NSRegularExpressionOptions)options range:(NSRange)range
Parameters
pattern |
The regular expression pattern to match. |
---|---|
templ |
The template to use for performing replacements of any matches found in the receiver. |
options |
The options that govern the behavior of the returned regular expression. |
range |
The range of characters in the receiver within which matching will occur. Characters outside this range will not be affected. |
Return Value
The number of matches performed.
Discussion
If the receiver contains any matches for the specified regular expression pattern, the receiver will be modified so that those matches are replaced according to the template provided.
Matching is constrained to the given range within the receiver.
Declared In
NSString+MBRegex.h
– replaceRegexMatches:withTemplate:options:range:error:
Performs a regular expression string replacement on the receiver.
- (NSUInteger)replaceRegexMatches:(nonnull NSString *)pattern withTemplate:(nonnull NSString *)templ options:(NSRegularExpressionOptions)options range:(NSRange)range error:(NSErrorPtrPtr)errPtr
Parameters
pattern |
The regular expression pattern to match. |
---|---|
templ |
The template to use for performing replacements of any matches found in the receiver. |
options |
The options that govern the behavior of the returned regular expression. |
range |
The range of characters in the receiver within which matching will occur. Characters outside this range will not be affected. |
errPtr |
An optional pointer to storage for an |
Return Value
The number of matches performed.
Discussion
If the receiver contains any matches for the specified regular expression pattern, the receiver will be modified so that those matches are replaced according to the template provided.
Matching is constrained to the given range within the receiver.
Declared In
NSString+MBRegex.h