Marcel Taeumel uploaded a new version of Regex-Core to project The Treated Inbox: http://source.squeak.org/treated/Regex-Core-ct.61.mcz
==================== Summary ====================
Name: Regex-Core-ct.61 Author: ct Time: 8 July 2021, 1:30:44.09436 am UUID: 63655b8f-ad42-0946-b6fe-4dc3100995f1 Ancestors: Regex-Core-ct.59
Adds String >> #escapeRegex to escape special characters in a string before composing it into another regex.
Usage:
':-)' matchesRegex: ':-)' escapeRegex
=============== Diff against Regex-Core-ct.59 ===============
Item was added: + ----- Method: RxParser class>>escapeString: (in category 'utilities') ----- + escapeString: aString + "Answer a copy of aString which does not contain any unescaped characters. This is the inverse function of String >> #matchesRegex:. + NB: Basically, we could simply escape every single character in the string, but this would not produce human-readable outputs." + + ^ aString + copyWithRegex: ('[{1}]' format: {self specialCharacters collect: [:character | '', character]}) + matchesTranslatedUsing: [:match | '', match]!
Item was added: + ----- Method: RxParser class>>specialCharacters (in category 'utilities') ----- + specialCharacters + + ^ #($( $) $[ $] $* $+ $? ${ $} $. $^ $$ $: $)!
Item was added: + ----- Method: String>>escapeRegex (in category '*Regex-Core') ----- + escapeRegex + + ^ RxParser escapeString: self!
packages@lists.squeakfoundation.org