How to resolve the algorithm Regular expressions step by step in the Smalltalk programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Regular expressions step by step in the Smalltalk programming language

Table of Contents

Problem Statement

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Regular expressions step by step in the Smalltalk programming language

Source code in the smalltalk programming language

|re s s1|
re := Regex fromString: '[a-z]+ing'.
s := 'this is a matching string'.
s1 := 'this does not match'.

(s =~ re)
ifMatched: [ :b |
   b match displayNl
].
(s1 =~ re)
ifMatched: [ :b |
   'Strangely matched!' displayNl
]
ifNotMatched: [
   'no match!' displayNl
].

(s replacingRegex: re with: 'modified') displayNl.

|re s s1|
re := 'm[a-z]+ing' asRegex.
s := 'this is a matching string'.
 
(re search: s) ifTrue: [ 'matches!' ].
 
s1 := re copy: s replacingMatchesWith: 'modified'.

  

You may also check:How to resolve the algorithm Gaussian elimination step by step in the Go programming language
You may also check:How to resolve the algorithm I before E except after C step by step in the Draco programming language
You may also check:How to resolve the algorithm Loops/Foreach step by step in the GAP programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the Beads programming language
You may also check:How to resolve the algorithm Write entire file step by step in the Pike programming language