<font face="Verdana,Arial,Helvetica,sans-serif" size="2"><div>Thanks Philippe. </div><div><br></div><div>I have created a pull request - <a href="https://github.com/apple/swift-corelibs-foundation/pull/273" target="_blank">https://github.com/apple/swift-corelibs-foundation/pull/273</a><br><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt"><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt"><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt"><div dir="ltr"><br><span style="font-family:georgia,serif;"><span style="font-size: 1.143em;">Pushkar N Kulkarni,</span></span></div>
<div dir="ltr"><span style="font-family:georgia,serif;"><span style="font-size: 1.143em;">IBM Runtimes</span></span></div>
<div dir="ltr"> </div>
<div dir="ltr"><em><span style="font-family:georgia,serif;"><span style="font-size: 0.857em;">"Any sufficiently advanced technology is indistinguishable from magic." - Arthur Clarke</span></span></em></div></div></div></div></font></div><br><br><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" color="#000000"><font color="#990099"><a href="mailto:-----phausler@apple.com" target="_blank">-----phausler@apple.com</a> wrote: -----</font><div class="iNotesHistory" style="padding-left:5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;">To: Pushkar N Kulkarni/India/IBM@IBMIN<br>From: Philippe Hausler <phausler@apple.com><br>Sent by: <a href="mailto:phausler@apple.com" target="_blank">phausler@apple.com</a><br>Date: 02/29/2016 10:40PM<br>Cc: <a href="mailto:swift-corelibs-dev@swift.org" target="_blank">swift-corelibs-dev@swift.org</a><br>Subject: Re: [swift-corelibs-dev] NSRegularExpression.escapedPatternForString() unimplemented on Linux<br><br><!--Notes ACF
<meta http-equiv="Content-Type" content="text/html charset=utf8">--><div class="">_CFRegularExpressionCreateEscapedPattern is exactly the same logic (except it is using CF types instead of NS types) so you can just implement that as a funnel to the CF call and it should do the right thing. The pattern metacharacters are already handled as they are in the objective-c version. The only behavioral differential that I can think of would be in the case of subclassing where a subclass of NSRE would actually call that subclass’s escape method instead of the base implementation; but if someone is brave enough to subclass NSRegularExpression I am certain they can probably work around that differential.</div><div class=""><br class=""></div><div class="">tl;dr just have that class method call <span style="font-family: 'Sans Serif', Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">_CFRegularExpressionCreateEscapedPattern and it should do what you want.</span></div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 29, 2016, at 4:07 AM, Pushkar N Kulkarni <<a href="mailto:pushkar.nk@in.ibm.com" class="">pushkar.nk@in.ibm.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><font face="Verdana,Arial,Helvetica,sans-serif" size="2" class=""><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">Thank you for the response, Phillippe.</div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><br class=""></div><div class=""><font face="Verdana, Arial, Helvetica, sans-serif" size="2" class="">I was wondering if the implementation would be exactly like NSRegularExpression.escapedTemplateForString(_:) which simply invokes </font><font face="Default Sans Serif, Verdana, Arial, Helvetica, sans-serif" size="2" class="">_CFRegularExpressionCreateEscapedPattern</font><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">(CFStringRef pattern)</span><font face="Default Sans Serif, Verdana, Arial, Helvetica, sans-serif" size="2" class="">. </font><span style="font-family: 'Default Sans Serif', Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">Alternatively, is it right to say that "template metacharacters" are a subset of "pattern metacharacters" ?</span></div><div class=""><font face="Default Sans Serif, Verdana, Arial, Helvetica, sans-serif" size="2" class=""><br class=""></font></div><div class=""><font face="Default Sans Serif, Verdana, Arial, Helvetica, sans-serif" size="2" class="">If the above isn't right, could you please describe the logic of the objective-C version of the escapedPatternForString(_:) class method?</font></div><div class=""><br class=""></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" class=""><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt"><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt"><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt"><div dir="ltr" class="">Regards,</div><div dir="ltr" class=""><span style="font-family:georgia,serif;" class=""><span style="font-size: 1.143em;" class="">Pushkar N Kulkarni,</span></span></div><div dir="ltr" class=""><span style="font-family:georgia,serif;" class=""><span style="font-size: 1.143em;" class="">IBM Runtimes</span></span></div><div dir="ltr" class=""> </div><div dir="ltr" class=""><em class=""><span style="font-family:georgia,serif;" class=""><span style="font-size: 0.857em;" class="">"Any sufficiently advanced technology is indistinguishable from magic." - Arthur Clarke</span></span></em></div></div></div></div></font></div><br class=""><br class=""><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><font color="#990099" class=""><a href="mailto:-----phausler@apple.com" target="_blank" class="">-----phausler@apple.com</a> wrote: -----</font><div class="iNotesHistory" style="padding-left:5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;" class="">To: Pushkar N Kulkarni/India/IBM@IBMIN<br class="">From: Philippe Hausler <!--Notes ACF
<phausler@apple.com class="">--><br class="">Sent by: <a href="mailto:phausler@apple.com" target="_blank" class="">phausler@apple.com</a><br class="">Date: 02/26/2016 08:47PM<br class="">Cc: <a href="mailto:swift-corelibs-dev@swift.org" target="_blank" class="">swift-corelibs-dev@swift.org</a><br class="">Subject: Re: [swift-corelibs-dev] NSRegularExpression.escapedPatternForString() unimplemented on Linux<br class=""><br class=""><!--Notes ACF
<meta http-equiv="Content-Type" content="text/html charset=utf8">-->To be honest I just didn’t get around to implementing that specific method in my initial implementation. There is a CF function that does that which could be wired up to provide a nearly identical backing to it. <div class=""><br class=""></div><div class="">CFStringRef _CFRegularExpressionCreateEscapedPattern(CFStringRef pattern)</div><div class=""><br class=""></div><div class="">should give you a good starting point to implement the NSRegularExpression side that should follow the same logic as the objective-c version.</div><div class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 26, 2016, at 3:28 AM, Pushkar N Kulkarni via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" class=""><div style="font-family: Verdana, Arial, Helvetica, sans-serif;" class="">Hello, </div><div style="font-family: Verdana, Arial, Helvetica, sans-serif;" class=""><br class=""></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif;" class="">I have a query regarding NSRegularExpression. I can see that the class method escapedPatternForString(), that escapes all characters in a string which could be treated as metacharacters, is unimplemented as per the latest dev snapshot for Linux.</div><div style="font-family: Verdana, Arial, Helvetica, sans-serif;" class=""><br class=""></div><div class=""><p style="font-family: Menlo; font-size: 14px; line-height: normal;" class=""><b class="">Welcome to Swift version 3.0-dev (LLVM f95d47afa7, Clang f66c5bb67b, Swift b745691a38). Type :help for assistance.</b></p><p style="font-family: Menlo; font-size: 14px; line-height: normal;" class=""><b class=""><font color="#a9a9a9" class=""> 1> </font>import Foundation</b></p><p style="font-family: Menlo; font-size: 14px; line-height: normal;" class=""><b class=""><font color="#a9a9a9" class=""> 2> </font>NSRegularExpression.escapedPatternForString("a+b")</b></p><p style="font-family: Menlo; font-size: 14px; line-height: normal;" class=""><b class="">fatal error: escapedPatternForString is not yet implemented: file Foundation/NSRegularExpression.swift, line 84</b></p><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" class=""><div class="socmaildefaultfont" dir="ltr" style="font-size: 10.5pt;"><div class="socmaildefaultfont" dir="ltr" style="font-size: 10.5pt;"><div class="socmaildefaultfont" dir="ltr" style="font-size: 10.5pt;"><div dir="ltr" style="font-family: Arial;" class=""><br class=""></div><div dir="ltr" class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class="">However, I see that this method is available on Swift 2.2-dev for OS X. </font></div><div dir="ltr" class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class=""><br class=""></font></div><div dir="ltr" class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class="">Could someone please tell me the rationale behind having it unimplemented for Linux? Were there any Linux-specific obstacles implementing it? We </font><span style="font-family: 'Sans Serif', Verdana, Arial, Helvetica, sans-serif; font-size: 10.5pt;" class="">would be glad to contribute here.</span></div><div dir="ltr" class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class=""><br class=""></font></div><div dir="ltr" class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class="">Thanks in advance.</font></div><div dir="ltr" style="font-family: Arial;" class=""><br class=""><span style="font-family:georgia,serif;" class=""><span style="font-size: 1.143em;" class="">Pushkar N Kulkarni</span></span></div><div dir="ltr" style="font-family: Arial;" class=""><span style="font-family:georgia,serif;" class=""><span style="font-size: 1.143em;" class="">IBM Runtimes</span></span></div><div dir="ltr" style="font-family: Arial;" class=""> </div><div dir="ltr" style="font-family: Arial;" class=""> </div><div dir="ltr" style="font-family: Arial;" class=""><em class=""><span style="font-family:georgia,serif;" class=""><span style="font-size: 0.857em;" class="">"Any sufficiently advanced technology is indistinguishable from magic." - Arthur Clarke</span></span></em></div></div></div></div></font></div></font><br class="">_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a><br class=""></div></blockquote></div><br class=""></div></div></div><!--Notes ACF
</phausler@apple.com>--></div></div></font></font><br class="">
</div></blockquote></div><br class=""></phausler@apple.com></div></div></font></font><BR>