Back: RecursionLock-printing Up: Base classes Forward: Regex class-instance creation   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.140 Regex

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

A Regex is a read-only string for which the regular expression matcher can cache a compiled representation, thus speeding up matching. Regex objects are constructed automatically by methods that expect to match many times the same regular expression, but can also be constructed explicitly sending #asRegex to a String or Symbol.

Creation of Regex objects inside a loop is of course slower than creating them outside the loop, but special care is taken so that the same Regex object is used whenever possible (when converting Strings to Regex, the cache is sought for an equivalent, already constructed Regex).

1.140.1 Regex class: instance creation  (class)
1.140.2 Regex: basic  (instance)
1.140.3 Regex: conversion  (instance)
1.140.4 Regex: printing  (instance)


1.140.1 Regex class: instance creation

fromString: aString
Like `aString asRegex'.

new
Do not send this message.


1.140.2 Regex: basic

at: anIndex put: anObject
Fail. Regex objects are read-only.

copy
Answer the receiver; instances of Regex are identity objects because their only purpose is to ease caching, and we obtain better caching if we avoid copying Regex objects


1.140.3 Regex: conversion

asRegex
Answer the receiver, which *is* a Regex!

asString
Answer the receiver, converted back to a String

species
Answer `String'.


1.140.4 Regex: printing

displayOn: aStream
Print a represention of the receiver on aStream. For most objects this is simply its #printOn: representation, but for strings and characters, superfluous dollars or extra pairs of quotes are stripped.

displayString
Answer a String representing the receiver. For most objects this is simply its #printString, but for strings and characters, superfluous dollars or extra pair of quotes are stripped.

printOn: aStream
Print a represention of the receiver on aStream.



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


This document was generated on February, 22 2012 using texi2html