Ticket #256 (new defect)

Opened 1 year ago

Last modified 1 month ago

RegExp: Follow Perl/.NET on RegExp capture syntax?

Reported by: lth Assigned to: lth
Type: defect Priority: major
Milestone: Component: Proposals
Version: Harmony Keywords: regexp
Cc: brendan

Description (last modified by lth) (diff)

Steven Levithan on es4-discuss notes that Perl and .NET have chosen a different named capture syntax than Python, and that PCRE has since adopted that syntax. He urges us to go with the majority.

This makes some sense, given our regexes' Perl heritage. The proposed syntax change would be:

  • captures are written (?<name> ...)
  • back-references are written \k<name> (the brockets are literal)

The new back-reference syntax is pretty ugly IMO, but this is what Perl/.NET supposedly do. (I need to verify that.)

See also #255 for a related issue.

Attachments

Change History

Changed 1 year ago by lth

  • description changed from Steven Levithan on es4-discuss notes that Perl and .NET have chosen a different named capture syntax than Python, and that PCRE has since adopted that syntax. He urges us to go with the majority. This makes some sense, given our regexes' Perl heritage, but the Proposed syntax change: * captures are written (?<name> ...), not (?P<name> ...) * back references are written \k<name> (the brockets are literal) The back reference syntax is pretty ugly IMO, but this is what Perl/.NET supposedly do. I need to verify that. See also #255 for a related issue. to Steven Levithan on es4-discuss notes that Perl and .NET have chosen a different named capture syntax than Python, and that PCRE has since adopted that syntax. He urges us to go with the majority. This makes some sense, given our regexes' Perl heritage. The proposed syntax change would be: * captures are written (?<name> ...) * back-references are written \k<name> (the brockets are literal) The new back-reference syntax is pretty ugly IMO, but this is what Perl/.NET supposedly do. (I need to verify that.) See also #255 for a related issue.

Changed 1 year ago by StevenLevithan

Both .NET and Perl support additional syntax for named capture beyond what is specified in this ticket's current description. I've outlined the differences between named capture syntax in all current languages which support the feature under the heading "Named capture" at http://stevenlevithan.com/regex/xregexp/ (which is the documentation page for a forthcoming JavaScript? library I'm working on).

Changed 1 year ago by lth

  • summary changed from Syntax: follow Perl/.NET on regexp capture syntax? to RegExp: Follow Perl/.NET on RegExp capture syntax?

Changed 1 month ago by David-Sarah Hopwood

  • keywords set to regexp
  • version changed from 4 to Harmony

Relevant proposal for ES-Harmony.

Note: See TracTickets for help on using tickets.