[swift-evolution] String update

Michael Ilseman milseman at apple.com
Wed Jan 17 17:43:10 CST 2018


That’s open for debate in the strawman. The parenthesis are performing two tasks: delimiting a capture and grouping. If we can split these two concepts, e.g. if we have non-capturing grouping, we could require that quantifiers on a capture be “sunk” into the subpattern. This would eliminate the issue.



> On Jan 17, 2018, at 2:08 PM, David Hart <david at hartbit.com> wrote:
> 
> While we’re on the topic of regular expressions, can someone confirm if the direction that the document is taking supports naming capture groups inside repeating patterns and automatically typing them to arrays?
> 
> let name = /
>     (let firstName: String <- \w+) \s
>     (let initials: [String] <- \w)* \s
>     (let lastName: String <- \w+)
>     /
> print(type(of: name)) // => Regex<(firstName: String, initials: [Character], lastName: String)>
> 
> On 16 Jan 2018, at 23:20, Michael Ilseman via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
>> Significant leading zeros is a good point. Another would be non-default-radix.
>> 
>>> On Jan 16, 2018, at 12:22 PM, C. Keith Ray via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> people may want digits as characters in order to see zeros. parsing phone numbers and social security numbers need zeros.
>>> 
>>> C. Keith Ray
>>> https://leanpub.com/wepntk <https://leanpub.com/wepntk> <- buy my book?
>>> http://agilesolutionspace.blogspot.com/ <http://agilesolutionspace.blogspot.com/>
>>> twitter: @ckeithray
>>> http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf <http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf>
>>> 
>>> On Jan 16, 2018, at 11:24 AM, Eneko Alonso via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>>> Digits could always be inferred to be numeric (Int) and they should always be “exact” (to match "\d"):
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>

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


More information about the swift-evolution mailing list