FANDOM


Smalltalk by example: Regular expressions

Introduction

GNU Smalltalk 2.3 introduced the Smalltalk.Regex class definition. After this, you should be able to succesfully run Regex inspect ! within gst.

Initialization

fromString is probably the best initialization to use.

|reg match|
reg := 'he.lo' asString.
reg asString "Returns the string 'he.lo'".
match := 'hello' =~ reg. "Returns a MatchingRegexResults "
match inspect .
!

Matching

For matchin a Regex to a pattern, the special =~ binary operator has been created.

Back to GST by example

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.