[swift-evolution] Empower String type with regular expression

Dany St-Amant dsa.mls at icloud.com
Mon Feb 1 21:43:31 CST 2016

> Le 31 janv. 2016 à 22:39, Chris Lattner via swift-evolution <swift-evolution at swift.org> a écrit :
>> On Jan 31, 2016, at 8:32 AM, Patrick Gili via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> There have been several threads that have discussed the notion of a regular expression literals. However, I didn't see anyone putting together a formal proposal, and hence I took the liberty to do so. I would appreciate discussion and comments on the proposal:
> I am +1 on the concept of adding regex literals to Swift, but -1 on this proposal.
> Specifically, instead of introducing regex literals, I’d suggest that you investigate introducing regex’s to the pattern grammar, which is what Swift uses for matching already.  Regex’s should be usable in the cases of a switch, for example.  Similarly, they should be able to bind variables directly to sub patterns.

I was seeing the sub patterns originally a bit like:
switch( string <match-op> regex) {
  case .matches(_, "http", let port):
  case .matches(_, let name, "8080"):
  case .matches(_, "\\smb\"):
but the comment about the pattern grammar make me of:
switch( string ) {
  case regexp1: if ($0.1 = "http") { }
  case regexp2:
Both have their uses


> Further, I highly recommend checking out Perl 6’s regular expressions.  They are a community that has had an obsessive passion for regular expressions, and in Perl 6 they were given the chance to reinvent the wheel based on what they learned.  What they came up with is very powerful, and pretty good all around.
> -Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160201/eb2427b4/attachment.html>

More information about the swift-evolution mailing list