<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi Marcel,</p>
<p><br>
</p>
<p>> <span>Why is #escapeString: inverse to #matchesRegex:? I am confused. :-)</span></p>
<p><span><br>
</span></p>
<p><span>Because of this:</span></p>
<p><span><br>
</span></p>
<p><span></p>
<div>':-)' matchesRegex: ':-)' escapeRegex "--> true"</div>
<div><br>
</div>
Well, mathematically spoken, this is not really an inverse function, I guess ... But something like this, I can't come up with the name. :-)</span>
<p></p>
<p><span><br>
</span></p>
<p><span>> <span>Hmm... "does not contain any unescaped characters" means "only contains escaped characters"?</span></span></p>
<p><span><span><br>
</span></span></p>
<p><span><span>Kind of. This comment was an inapt attempt of communicating that only special characters will be escaped. Otherwise, we could just prepend every character with a backslash, this would be total escaping, but hard to read. :-)</span></span></p>
<p><span><br>
</span></p>
<p><span>Sure, the names are completely open to discussion, I only tried to be consistent with #escapeHtmlText. The problem is that we need to encode the semantic role of the receiver in selector names like this. #asRegexEscaped sounds to me as if it would
 answer an RxMatcher which is not the case. #escapedRegex would be possible but is not aligned with #escapeHtmlText. Hm ... Any other ideas? :-)</span></p>
<p><span><br>
</span></p>
<p><span>Best,</span></p>
<p><span>Christoph</span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel<br>
<b>Gesendet:</b> Donnerstag, 8. Juli 2021 09:06:51<br>
<b>An:</b> squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] The Inbox: Regex-Core-ct.61.mcz</font>
<div> </div>
</div>
<div>
<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
Hi Christoph,
<div><br>
</div>
<div>I like the feature, I am not sure about the selectors you've chosen.</div>
<div><br>
</div>
<div>#escapeString:</div>
<div>#escapeRegex</div>
<div>#specialCharacters</div>
<div><br>
</div>
<div>I couldn't find any good examples in the image:</div>
<div><br>
</div>
<div>String >> #encodeForHTTP</div>
<div>String >> #unescapePercents</div>
<div>Character >> #escapeEntities (not used at all?!)</div>
<div><br>
</div>
<div>Hmm... maybe #reservedCharacters instead of #specialCharacters? Maybe #escapedRegex instead of #escapeRegex? <span style="font-size: 10pt">And maybe String >> #asRegexEscaped?</span></div>
<div><br>
</div>
<div>Hmm... "<span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">does not contain any unescaped characters" means "only contains escaped characters"? Why is #escapeString: inverse to #matchesRegex:? I am confused. :-) The current names do
 not help me here.</span></div>
<div><br>
</div>
<div>Best,<br>
Marcel</div>
<div><br>
</div>
<div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 08.07.2021 01:30:52 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">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>
+ matchesTranslatedUsing: [:match | '\', match]!<br>
<br>
Item was added:<br>
+ ----- Method: RxParser class>>specialCharacters (in category 'utilities') -----<br>
+ specialCharacters<br>
+ <br>
+ ^ #($( $) $[ $] $* $+ $? ${ $} $. $^ $$ $: $\)!<br>
<br>
Item was added:<br>
+ ----- Method: String>>escapeRegex (in category '*Regex-Core') -----<br>
+ escapeRegex<br>
+ <br>
+ ^ RxParser escapeString: self!<br>
<br>
<br>
</div>
</blockquote>
</div>
</div>
</body>
</html>