Hi Levente,<br>
<br>
two very fair points, thank you for the feedback! Revisiting #escapeString: again, we do not even need to compile a new regex, which is <i>really</i> expensive, but we can use a simple loop instead:<br>
<br>
<font color="#000000">    </font><font color="#808080">|</font><font color="#000000"> </font><font color="#6B6B6B">special</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"><br>
    </font><font color="#6B6B6B">special</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">specialCharacters</font><font color="#000000">.<br>
    </font><font color="#800000">^</font><font color="#000000"> String </font><font color="#000080">streamContents:</font><font color="#000000"> [:</font><font color="#000080">stream</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"><br>
        </font><font color="#000080">aString</font><font color="#000000"> </font><font color="#000080">do:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#000000">:</font><font color="#000080">char</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"><br>
            </font><font color="#800080">(</font><font color="#6B6B6B">special</font><font color="#000000"> </font><font color="#000080">includes:</font><font color="#000000"> </font><font color="#000080">char</font><font color="#800080">)</font><font color="#000000"> </font><font color="#000080">ifTrue:</font><font color="#000000"> </font><font color="#800080">[</font><font color="#000080">stream</font><font color="#000000"> </font><font color="#000080">nextPut:</font><font color="#000000"> </font><font color="#800000">$\</font><font color="#800080">]</font><font color="#000000">.<br>
            </font><font color="#000080">stream</font><font color="#000000"> </font><font color="#000080">nextPut:</font><font color="#000000"> </font><font color="#000080">char</font><font color="#008000">]</font><font color="#000000">]</font><br>
<br>
Which is 90% faster than the original approach. :-)<br>
I will upload a new inbox version when we have made progress with the current naming discussion.<br>
<br>
Best,<br>
Christoph<br>
<br>
> Hi Christoph,<br>
> <br>
> On Wed, 7 Jul 2021, commits at source.squeak.org wrote:<br>
> <br>
> > A new version of Regex-Core was added to project The Inbox:<br>
> > http://source.squeak.org/inbox/Regex-Core-ct.61.mcz<br>
> ><br>
> > ==================== Summary ====================<br>
> ><br>
> > Name: Regex-Core-ct.61<br>
> > Author: ct<br>
> > Time: 8 July 2021, 1:30:44.09436 am<br>
> > UUID: 63655b8f-ad42-0946-b6fe-4dc3100995f1<br>
> > Ancestors: Regex-Core-ct.59<br>
> ><br>
> > Adds String >> #escapeRegex to escape special characters in a string before composing it into another regex.<br>
> ><br>
> > Usage:<br>
> ><br>
> >     ':-)' matchesRegex: ':-)' escapeRegex<br>
> ><br>
> > =============== Diff against Regex-Core-ct.59 ===============<br>
> ><br>
> > Item was added:<br>
> > + ----- Method: RxParser class>>escapeString: (in category 'utilities') -----<br>
> > + escapeString: aString<br>
> > +     "Answer a copy of aString which does not contain any unescaped characters. This is the inverse function of String >> #matchesRegex:.<br>
> > +     NB: Basically, we could simply escape every single character in the string, but this would not produce human-readable outputs."<br>
> > + <br>
> > +     ^ aString<br>
> > +         copyWithRegex: ('[{1}]' format: {self specialCharacters collect: [:character | '\', character]})<br>
> <br>
> That first argument doesn't look right. If you evaluate it, you'll get<br>
> <br>
>   '[#(''\('' ''\)'' ''\['' ''\]'' ''\*'' ''\+'' ''\?'' ''\{'' ''\}'' ''\.'' ''\^'' ''\$'' ''\:'' ''\\'')]'<br>
> <br>
> I think you need something like this:<br>
> <br>
> String streamContents: [ :stream |<br>
>      stream nextPut: $[.<br>
>      self specialCharacters do: [ :each |<br>
>          stream nextPut: $\; nextPut: each ].<br>
>      stream nextPut: $] ]<br>
> <br>
> which yields<br>
> <br>
>   '[\(\)\[\]\*\+\?\{\}\.\^\$\:\\]'<br>
> <br>
> <br>
> > Item was added:<br>
> > + ----- Method: RxParser class>>specialCharacters (in category 'utilities') -----<br>
> > + specialCharacters<br>
> > + <br>
> > +     ^ #($( $) $[ $] $* $+ $? ${ $} $. $^ $$ $: $\)!<br>
> <br>
> Why not just ^'()[]*+?{}.^$:\'?<br>
> <br>
> <br>
> Levente<br>
> <br>