[erlang-questions] Adoption of perl/javascript-style regexp syntax

Tony Arcieri tony@REDACTED
Wed Jun 3 20:14:52 CEST 2009


On Wed, Jun 3, 2009 at 12:00 AM, Tony Arcieri <tony@REDACTED> wrote:

> On Tue, Jun 2, 2009 at 11:03 PM, Richard O'Keefe <ok@REDACTED>wrote:
>
>> It would be nice to tag the matches one wants with atoms rather
>> than invisible integers.
>
>
> I've thought about combining pattern matching with named capture groups,
> ala:
>
> /(?<a>f.o)(?<b>b.r)(?<c>b.z)/ = "foobarbaz"
>
> would bind:
>
> a: "foo"
> b: "bar"
> c: "baz"
>
> If nothing else, I could support the Ruby 1.9 syntax:
>
> >> "foobarbaz".match(/(?<a>f.o)(?<b>b.r)(?<c>b.z)/)[:b]
> => "bar"


I'd also like to note: the main reason I haven't implemented nifty
functionality with named capture groups yet is because the re module
provides no interface to getting a list of the capture group names out of a
compiled regex.  I'm not the only one who's been bitten by this problem
either:

http://www.nabble.com/Extracting-capture-group-names-from-regular-expressions-td19848494.html

-- 
Tony Arcieri
medioh.com


More information about the erlang-questions mailing list