Next: , Previous: String-printing, Up: String


1.155.9 String: regex

=~ pattern
Answer a RegexResults object for matching the receiver against the Regex or String object pattern.


allOccurrencesOfRegex: pattern
Find all the matches of pattern within the receiver and collect them into an OrderedCollection.


allOccurrencesOfRegex: pattern do: aBlock
Find all the matches of pattern within the receiver and pass the RegexResults objects to aBlock.


allOccurrencesOfRegex: pattern from: from to: to
Find all the matches of pattern within the receiver and within the given range of indices. Collect them into an OrderedCollection, which is then returned.


allOccurrencesOfRegex: pattern from: from to: to do: aBlock
Find all the matches of pattern within the receiver and within the given range of indices. For each match, pass the RegexResults object to aBlock.


asRegex
Answer the receiver, converted to a Regex object.


copyFrom: from to: to replacingAllRegex: pattern with: aStringOrBlock
Returns the substring of the receiver between from and to. Any match of pattern in that part of the string is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).


copyFrom: from to: to replacingRegex: pattern with: aStringOrBlock
Returns the substring of the receiver between from and to. If pattern has a match in that part of the string, the match is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).


copyReplacingAllRegex: pattern with: aStringOrBlock
Returns the receiver after replacing all the matches of pattern (if any) using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).


copyReplacingRegex: pattern with: aStringOrBlock
Returns the receiver after replacing the first match of pattern (if any) using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).


indexOfRegex: regexString
If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match. Otherwise return nil.


indexOfRegex: regexString from: from to: to
If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match occurring within the given range of indices. Otherwise return nil.


indexOfRegex: regexString from: from to: to ifAbsent: excBlock
If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match occurring within the given indices. Otherwise, evaluate excBlock and return the result.


indexOfRegex: regexString ifAbsent: excBlock
If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match. Otherwise, evaluate excBlock and return the result.


indexOfRegex: regexString startingAt: index
If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match starting after the given index. Otherwise return nil.


indexOfRegex: regexString startingAt: index ifAbsent: excBlock
If an occurrence of the regex is present in the receiver, return the Interval corresponding to the leftmost-longest match starting after the given index. Otherwise, evaluate excBlock and return the result.


matchRegex: pattern
Answer whether the receiver is an exact match for the pattern. This means that the pattern is implicitly anchored at the beginning and the end.


matchRegex: pattern from: from to: to
Answer whether the given range of indices is an exact match for the pattern. This means that there is a match starting at from and ending at to (which is not necessarily the longest match starting at from).


occurrencesOfRegex: pattern
Returns count of how many times pattern repeats in the receiver.


occurrencesOfRegex: pattern from: from to: to
Return a count of how many times pattern repeats in the receiver within the given range of index.


occurrencesOfRegex: pattern startingAt: index
Returns count of how many times pattern repeats in the receiver, starting the search at the given index.


onOccurrencesOfRegex: pattern do: body
Find all the matches of pattern within the receiver and, for each match, pass the RegexResults object to aBlock.


onOccurrencesOfRegex: pattern from: from to: to do: aBlock
Find all the matches of pattern within the receiver and within the given range of indices. For each match, pass the RegexResults object to aBlock.


replacingAllRegex: pattern with: aStringOrBlock
Returns the receiver if the pattern has no match in it. Otherwise, any match of pattern in that part of the string is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).


replacingRegex: pattern with: aStringOrBlock
Returns the receiver if the pattern has no match in it. If it has a match, it is replaced using aStringOrBlock as follows: if it is a block, a RegexResults object is passed, while if it is a string, %n sequences are replaced with the captured subexpressions of the match (as in #%).


searchRegex: pattern
A synonym for #=~. Answer a RegexResults object for matching the receiver against the Regex or String object pattern.


searchRegex: pattern from: from to: to
Answer a RegexResults object for matching the receiver against the Regex or String object pattern, restricting the match to the specified range of indices.


searchRegex: pattern startingAt: anIndex
Answer a RegexResults object for matching the receiver against the Regex or String object pattern, starting the match at index anIndex.


tokenize: pattern
Split the receiver at every occurrence of pattern. All parts that do not match pattern are separated and stored into an Array of Strings that is returned.


tokenize: pattern from: from to: to
Split the receiver at every occurrence of pattern (considering only the indices between from and to). All parts that do not match pattern are separated and stored into an Array of Strings that is returned.


~ pattern
Answer whether the receiver matched against the Regex or String object pattern.