Back: Regex-printing Up: Base classes Forward: RegexResults-accessing   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.141 RegexResults

Defined in namespace Smalltalk
Superclass: Object
Category: Collections-Text

I hold the results of a regular expression match, and I can reconstruct which parts of the matched string were assigned to each subexpression. Methods such as #=~ return RegexResults objects, while others transform the string directly without passing the results object back to the caller.

1.141.1 RegexResults: accessing  (instance)
1.141.2 RegexResults: testing  (instance)


1.141.1 RegexResults: accessing

asArray
If the regular expression was matched, return an Array with the subexpressions that were present in the regular expression.

at: anIndex
If the regular expression was matched, return the text of the anIndex-th subexpression in the successful match.

from
If the regular expression was matched, return the index of the first character in the successful match.

fromAt: anIndex
If the regular expression was matched, return the index of the first character of the anIndex-th subexpression in the successful match.

intervalAt: anIndex
If the regular expression was matched, return an Interval for the range of indices in the anIndex-th subexpression of the successful match.

match
If the regular expression was matched, return the text of the successful match.

matchInterval
If the regular expression was matched, return an Interval for the range of indices of the successful match.

size
If the regular expression was matched, return the number of subexpressions that were present in the regular expression.

subject
If the regular expression was matched, return the text that was matched against it.

to
If the regular expression was matched, return the index of the last character in the successful match.

toAt: anIndex
If the regular expression was matched, return the index of the last character of the anIndex-th subexpression in the successful match.


1.141.2 RegexResults: testing

ifMatched: oneArgBlock
If the regular expression was matched, pass the receiver to oneArgBlock and return its result. Otherwise, return nil.

ifMatched: oneArgBlock ifNotMatched: zeroArgBlock
If the regular expression was matched, evaluate oneArgBlock with the receiver as the argument. If it was not, evaluate zeroArgBlock. Answer the result of the block's evaluation.

ifNotMatched: zeroArgBlock
If the regular expression was matched, return the receiver. If it was not, evaluate zeroArgBlock and return its result.

ifNotMatched: zeroArgBlock ifMatched: oneArgBlock
If the regular expression was matched, evaluate oneArgBlock with the receiver as the argument. If it was not, evaluate zeroArgBlock. Answer the result of the block's evaluation.

matched
Answer whether the regular expression was matched



Back: RegexResults-accessing Up: RegexResults Forward: RootNamespace   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on April, 16 2013 using texi2html