Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Regular-expressions/Smalltalk/regular-expressions-1.st
Normal file
18
Task/Regular-expressions/Smalltalk/regular-expressions-1.st
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|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.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|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'.
|
||||
Loading…
Add table
Add a link
Reference in a new issue