[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27659: 26.0.50; Add string-matched-text: string-match + match-string

From: Philipp Stephani
Subject: bug#27659: 26.0.50; Add string-matched-text: string-match + match-string
Date: Sun, 23 Jul 2017 20:41:36 +0000

Stefan Monnier <address@hidden> schrieb am Fr., 21. Juli 2017 um 15:34 Uhr:
>> This looks useful, but I think it would be even better to add it
>> as a pcase macro to be composable (see attached patch). 

Hey, very nice.  Please add it to rx.el.
[ But please change `backref-var` to just `backref` (you can distinguish
  the two based on the type of the argument, I think).  I guess one
  could also argue that you could similarly rename the `let` to
  `group-n`.  ]

Pushed as ad4eff3b905dbc32e2d38bfec1e4f93eceec288d. I've renamed backref-var to backref as you suggested, but left `let' because I think that feature is important enough to deserve a short, common name.

> Although, i must admit i am not fluent in `rx' syntaxis, i find your idea
> very nice.

If you prefer the standard/cryptic regexp syntax, I posted a similar
thingy in the past (see below).

This lets you do

    (pcase "foo-123"
      ((re-match "[[:alpha:]]+-\\(?num:[0-9]+\\)")
    => "123"

Maybe I should install it in pcase.el?

Sure! I'd suggest to change the syntax to be compatible with other languages:

\(?<abc>[0-9]+\) or \(?'abc'[0-9+\) (Perl and .NET)
\(?P<abc>[0-9]+\) (Python)

These languages also have syntax for named backreferences, though that's less important. 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]