<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Assuming we’re still on track for getting an official package manager in Swift 3…<div class=""><br class=""></div><div class="">I vote we put the traditional regex in the stdlib, either as a non-final class or in combination with a “RegularExpressionParser” protocol, and make these “non-standard” parsers compatible with the stdlib implementation (that is, subclass the stdlib parser or conform to the protocol), and put them up in the package manager. “Swift Verbal Expressions" looks very cool, but I’m not sure it’s “lean &amp; mean” enough for the stdlib.</div><div class=""><br class=""><div class="">
- Dave Sweeris

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 15:53, Howard Lovatt via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I don't see that the two have to be exclusive. If the design of the regex literal is suitable for both a traditional NSRegularExpression and a verbal type implementation then the two can co-exist. It can also be staged, so that a literal can be introduced first with a bridge to legacy NSRegularExpression and then later a verbal implementation could be added. The key is to design a liberal that is future proofed.&nbsp;</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On 3 February 2016 at 10:33, Patrick Gili <span dir="ltr" class="">&lt;<a href="mailto:gili.patrick.r@gili-labs.com" target="_blank" class="">gili.patrick.r@gili-labs.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">I don't feel good about this direction for the following reasons:<div class="">1) Complexity</div><div class="">2) Maturity? I don't know how Verbal Expressions has been implemented. Does it leverage mature regex open source? Or, has it been written from scratch?</div><div class="">3) Performance? Compiling a regex literal typically results in a FSM of a sort, optimized to parse strings. I wouldn't think that converting a regex literal to Verbal Expressions would yield great performance every time a match or substitution is done.</div><div class=""><br class=""></div><div class="">-Patrick</div><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 5:55 PM, Howard Lovatt &lt;<a href="mailto:howard.lovatt@gmail.com" target="_blank" class="">howard.lovatt@gmail.com</a>&gt; wrote:</div><br class=""><div class="">The difference is that I am proposing supporting both verbal expressions and regex&nbsp;literals and that - literals are converted to verbals and the processing happens at the verbal level. The reason for this is that verbals are easy to handle programmatically whilst literals are great for quickly specifying a regex.<br class=""><br class="">On Tuesday, 2 February 2016, Patrick Gili &lt;<a href="mailto:gili.patrick.r@gili-labs.com" target="_blank" class="">gili.patrick.r@gili-labs.com</a>&gt; wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Howard,<div class=""><br class=""></div><div class="">I don't see how this is very different from the Swift Verbal Expressions. It would suffer from the same disadvantages I have stated previously.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Patrick</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 1:51 AM, Howard Lovatt via swift-evolution &lt;<a class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">Others have suggested a programatic regex instead of a regex literal, how about doing both? Something like:<div class=""><br class=""></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">enum</span> RegexElement {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">case</span> capture(name: String, value: String)</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">case</span> special(Special)</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// ...</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">enum</span> Special: <span style="color:rgb(112,61,170)" class="">String</span> {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">case</span> startOfLine = <span style="color:rgb(209,47,27)" class="">"^"</span></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(0,132,0)" class="">// ...</span></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">case</span> endOfLine = <span style="color:rgb(209,47,27)" class="">"$"</span></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; }</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class="">// Define a regexLiteral syntax that the compiler understands that is of type Regex and consists of String representations of RegexElements, e.g. using forward slash:</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class="">//&nbsp; &nbsp; /&lt;RegexElements&gt;*/</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span style="color:rgb(187,44,162)" class="">struct</span><span class=""> Regex: </span><span style="color:rgb(112,61,170)" class="">CustomStringConvertible</span><span class=""> { </span>// Compiled, immutable, thread safe, and bridged to NSRegularExpression</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// ... internal compiled representation</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">let</span> elements: [<span style="color:rgb(79,129,135)" class="">RegexElement</span>]</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">var</span> description: <span style="color:rgb(112,61,170)" class="">String</span> {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">return</span><span class=""> </span><span style="color:rgb(79,129,135)" class="">RegexElement</span><span class="">.</span><span style="color:rgb(79,129,135)" class="">Special</span><span class="">.</span><span style="color:rgb(49,89,93)" class="">startOfLine</span><span class="">.</span><span style="color:rgb(79,129,135)" class="">rawValue</span><span class=""> </span>// Example. Really returns all the elements converted back to a string</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; }</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">init</span>(<span style="color:rgb(187,44,162)" class="">_</span> elements: <span style="color:rgb(79,129,135)" class="">RegexElement</span>...) {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">self</span><span class="">.</span><span style="color:rgb(79,129,135)" class="">elements</span><span class=""> = elements </span>// Example. Really also compiles the expression</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; }</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// init(regexLiteral regex: Regex) {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// init(concatAll regexes: Regex...) {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// init(fromString string: String) {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// ... more inits</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">func</span> map&lt;T&gt;(input: <span style="color:rgb(112,61,170)" class="">String</span>, <span style="color:rgb(187,44,162)" class="">@noescape</span> mapper: (element: <span style="color:rgb(79,129,135)" class="">RegexElement</span>) <span style="color:rgb(187,44,162)" class="">throws</span> -&gt; <span style="color:rgb(79,129,135)" class="">T</span>) <span style="color:rgb(187,44,162)" class="">rethrows</span> -&gt; [<span style="color:rgb(79,129,135)" class="">T</span>] {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:rgb(187,44,162)" class="">return</span><span class=""> [</span><span style="color:rgb(187,44,162)" class="">try</span><span class=""> mapper(element: </span><span style="color:rgb(79,129,135)" class="">RegexElement</span><span class="">.</span><span style="color:rgb(49,89,93)" class="">special</span><span class="">(.</span><span style="color:rgb(49,89,93)" class="">startOfLine</span><span class="">))] </span>// Example. Really does the matching</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; }</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// func flatMap&lt;T&gt;(input: String, @noescape mapper: (element: RegexElement) throws -&gt; T?) rethrows -&gt; [T] {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// func flatMap&lt;S: SequenceType&gt;(input: String, @noescape mapper: (element: RegexElement) throws -&gt; S) rethrows -&gt; [S.Generator.Element] {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// func forEach(input: String, @noescape eacher: (element: RegexElement) throws -&gt; Void) rethrows {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; </span>// ... more funcs</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span style="color:rgb(187,44,162)" class="">let</span><span class=""> regex = </span><span style="color:rgb(79,129,135)" class="">Regex</span><span class="">(</span><span style="color:rgb(79,129,135)" class="">RegexElement</span><span class="">.</span><span style="color:rgb(49,89,93)" class="">special</span><span class="">(.</span><span style="color:rgb(49,89,93)" class="">startOfLine</span><span class="">)) </span>// Normally a regex literal</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">let</span> asStringArray = <span style="color:rgb(79,129,135)" class="">regex</span>.<span style="color:rgb(49,89,93)" class="">map</span>(<span style="color:rgb(209,47,27)" class="">"Example"</span>) { element -&gt; <span style="color:rgb(112,61,170)" class="">String</span> <span style="color:rgb(187,44,162)" class="">in&nbsp;</span><span style="color:rgb(0,132,0)" class="">// Returns `["^"]` in example</span></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">switch</span> element {</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">case</span> <span style="color:rgb(187,44,162)" class="">let</span> .capture(<span style="color:rgb(187,44,162)" class="">_</span>, v): <span style="color:rgb(187,44,162)" class="">return</span> v</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">case</span> <span style="color:rgb(187,44,162)" class="">let</span> .special(s): <span style="color:rgb(187,44,162)" class="">return</span> s.<span style="color:rgb(79,129,135)" class="">rawValue</span></div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; }</div></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div></div></blockquote><div class=""><br class=""></div><div class="">The advantages are:</div><div class=""><ol class=""><li class="">&nbsp; We get a literal type for convenience.<br class=""></li><li class="">&nbsp; We get a programatic type when we need to manipulate regexes.<br class=""></li><li class="">&nbsp; Breaking the regex matches into the enum defined elements of the regex works well with Swift pattern matching.<br class=""></li></ol></div><div class="">(Above is a very rough sketch!)</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On 2 February 2016 at 16:44, Thorsten Seitz via swift-evolution <span dir="ltr" class="">&lt;<a class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class=""><span class=""></span></div><div class=""><div class=""></div><div class="">Something like Scala's extractors or F#'s Active Patterns would be most welcome to generalize pattern matching.</div><div class=""><br class=""></div><div class=""><a href="http://docs.scala-lang.org/tutorials/tour/extractor-objects.html" target="_blank" class="">http://docs.scala-lang.org/tutorials/tour/extractor-objects.html</a></div><div class=""><a href="https://en.m.wikibooks.org/wiki/F_Sharp_Programming/Active_Patterns" target="_blank" class="">https://en.m.wikibooks.org/wiki/F_Sharp_Programming/Active_Patterns</a></div><div class=""><br class=""></div><div class="">-Thorsten&nbsp;</div><div class=""><br class="">Am 01.02.2016 um 15:46 schrieb James Campbell via swift-evolution &lt;<a class="">swift-evolution@swift.org</a>&gt;:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">It would be great if we could create a generic way of making this swifty. You may let say want to implement a matching system for structure like JSON or XML (i.e XQuery).<div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><p class=""><b class=""><font color="#cc0000" class="">___________________________________</font></b></p><p class=""><b class="">James⎥Lead Engineer</b></p><p class=""><b class=""><font color="#cc0000" class=""><a class="">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank" class="">supmenow.com</a></font></b></p><p class=""><b class=""><font size="2" class="">Sup</font></b></p><p class=""><b class=""><font size="2" class="">Runway East
</font></b></p><p class=""><b class=""><font size="2" class="">10 Finsbury Square</font></b></p><p class=""><b class=""><font size="2" class="">London</font></b></p><p class=""><b class=""><font size="2" class="">
EC2A 1AF&nbsp;</font></b></p></div></div></div></div></div>
<br class=""><div class="gmail_quote">On Mon, Feb 1, 2016 at 2:43 PM, Patrick Gili via swift-evolution <span dir="ltr" class="">&lt;<a class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Dany,<div class=""><br class=""></div><div class="">My response is inline below.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Patrick</div><div class=""><br class=""></div><div class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jan 31, 2016, at 8:56 PM, Dany St-Amant &lt;<a class="">dsa.mls@icloud.com</a>&gt; wrote:</div><br class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><blockquote type="cite" class=""><div class=""><br class="">Le 31 janv. 2016 à 16:46, Patrick Gili &lt;<a class="">gili.patrick.r@gili-labs.com</a>&gt; a écrit :</div><br class=""><div class=""><div style="word-wrap:break-word" class="">Hi Dany,<div class=""><br class=""></div><div class="">Please find my response inline below.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Patrick</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 31, 2016, at 3:46 PM, Dany St-Amant via swift-evolution &lt;<a class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">This seem to be two proposals in one:</div><div class="">1. Initialize NSRegularExpression with a single String which includes options</div><div class=""><br class=""></div><div class="">The ultimate goal based on the earlier mail in the thread seems to be able in a future proposal do thing like: string ~= replacePattern, if string =~ pattern, decoupled from the legacy Obj-C. Isn’t NSRegularExpression part of the legacy? The conversion of the literal string as regular expression should probably part of the proposal for these operators; as this is the time we will know how we want the text to be interpreted.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I don't see any evidence of NSRegularExpression becoming part of any legacy. Given SE-005, SE-006, and SE-023, the name is probably changing from NSRegularExpression to RegularExpression. However, I don't think the definition of the class will change, only the name.</div><div class=""><br class=""></div><div class="">I would like to see an operator regular expression matching operator, like Ruby and Perl. I was trying to keep the proposal a minimal increment that would buy the biggest bang for the buck. We can already accomplish much of what other languages can do with regard to regular expression. However, the notion of a regular expression isn't something we can work around with custom library today. Can you suggest something addition that should be in the proposal?</div></div></div></div></div></blockquote><div class=""><br class=""></div>Splitting proposal in smaller ones have its advantage, but here I am just wondering if we are sure that these future operation will use the NSRegularExpression/RegularExpression. And does the currently selected syntax allow for future expansion, it would be bad to introduce something &nbsp;that need to be torn away or changed in an incompatible way, once we really start to use them in their final location.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">The proposal is focused on the search, but seem to skip the substitution; I am unable to see an option to replace all matches instead of the first one only in the proposal. I, as many other, would expect regular expression in a language to also support substitution.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">As for addition to the proposal, the processing of the string could be support for any character (within some limit) for the slash delimiter. With sed, when replacing &nbsp;path component, one can do:&nbsp;<span style="font-family:Menlo;font-size:11px" class="">echo $PWD | sed -e "s:^/usr/local/bin:/opt/share/bin:g"</span>, instead of escaping every single slashes. Which is really handy to make thing easier to read.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">Also, putting aside that I think \(scheme) should not be interpreted in the example, with a syntax allowing such interpretation the variable should be processed to generate proper escaping. If one is to use \(filename) you get "main.c", but one must use \(filename.escaped()) to get the proper "main\.c" to avoid matching "mainac". The String.escaped() must be in a format compatible with the format used when converting the regular expression into NSRegularExpression (not sure if the two syntax are the same; I think that at least the handling of / &nbsp;may differ)</div></div></blockquote><div class=""><br class=""></div></span><div class="">I agree. Perhaps I went too far with keeping the proposal short-and-sweet. Especially when you consider the rich syntax that Perl supports for substitution.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">2. Easily create a String without escaping (\n is not linefeed, but \ and n)</div><div class=""><br class=""></div><div class="">The ability to not interpret the backslash as escape can be useful in other scenario that creating a NSRegularExpression; like creating a Windows pathname, or creating regular expression which are then given to external tool.&nbsp; So this part of the proposal should probably be generalized.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Generalize it for what? If you're thinking along the line of raw strings, I agree that we need this capability, as well as multi-line string literals. However, I just soon we have separate proposals for this.</div></div></div></div></div></blockquote><div class=""><br class=""></div>My point/opinion here, is that a regular expressions are just a String which are then interpreted; the same way as "Good Morning", "Bonjour", or "Marhaba" (even when using the arabic script) are just String when you assign then to a variable in Swift, and then interpreted by the intended user. They are not String, frenchString, rigthToLeftString. So I do not see why a regular expression should have privileged treatment and have its own language level syntax. The only difference when writing regular expression, or Windows pathname, or any String with a syntax with heavily uses of backslashes, is that one may want to disable the special meaning of the backslashes, to make thing more readable.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">On the page of geeky-ing the String there’s four main part IMHO</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">- multi-line support</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">- no backslash escaping version (which should include no processing the \(variable) format)</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">- inclusion of String delimiter inside the String</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">- concat of backslash/no backslash version. Bash example&nbsp;<span style="font-family:Menlo;font-size:11px" class="">echo</span><span style="font-family:Menlo;font-size:11px" class="">&nbsp;</span><span style="font-family:Menlo;font-size:11px" class="">'echo "$BASH" shows '"$BASH"</span></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">I’m still trying to find back the mail thread crumbs on these topics, since before restarting the discussion in these topics, the previous one should be properly summarized; unless such summary already exist.</div></div></blockquote><div class=""><br class=""></div></span><div class="">I think supporting interpolation is important. Both Perl and Ruby support it, and I'm sure there are other languages. One thing I forgot to put into the proposal: an option to disable interpolation or limit it to single pass.</div><div class=""><br class=""></div><div class="">Looking ahead at the other responses, Chris Lattner has suggested that the proposal would have more traction if we can find a way to fold this into Swift's pattern matching. I can't say as I disagree, as this makes regular expression more Swifty.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">Regards,</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">Dany</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap:break-word" class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">Dany</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">Le 31 janv. 2016 à 12:18, Patrick Gili via swift-evolution &lt;<a class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class=""><div class=""><div style="word-wrap:break-word" class="">Here is the link to the proposal on GitHub:<div class=""><br class=""></div><div class=""><a href="https://github.com/gili-patrick-r/swift-evolution/blob/master/proposals/NNNN-regular-expression-literals.md" target="_blank" class="">https://github.com/gili-patrick-r/swift-evolution/blob/master/proposals/NNNN-regular-expression-literals.md</a></div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Patrick</div></div></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></span></div><br class=""></div></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div>-- <br class=""><div class="">&nbsp; -- Howard.<br class=""></div>
</font></span></div><span class="HOEnZb"><font color="#888888" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></font></span></div></blockquote></div><span class="HOEnZb"><font color="#888888" class=""><br class=""></font></span></div></div></blockquote><span class="HOEnZb"><font color="#888888" class=""><br class=""><br class="">-- <br class="">&nbsp; -- Howard.<br class=""><br class="">
</font></span></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature">&nbsp; -- Howard.<br class=""></div>
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>