On 18/05/18 13:30, The Sidhekin wrote:
> On Thu, May 17, 2018 at 12:51 PM, Timo Paulssen <t...@wakelift.de
> <mailto:t...@wakelift.de>> wrote:
>
>     character classes are fundamentally the wrong thing for "phrases",
>     since they describe only a character.
>
>
>   You were right the first time.

I'm not sure what you're referring to here?

>  [...]
>
>   Somewhat interesting exercise, but this kind of rephrasing doesn't
> scale well for longer phrases, is hard to automate (given a phrase,
> which character classes need we use?), and it's already pretty hard to
> read.

That's true, it's probably not sensible to do every regex this way. I'm
not sure how I could have done it better, though.

>   If this requirement needs to be expressed in a single regex, here's
> what I'd use (quickly translated from Perl5, then tested to get rid of
> translation errors):
>
>   /<!before .* gm> ^ <[d..z]>* $/
>
>   ... or, with comments:
>
>   /<!before .* gm> # not containing the phrase "gm" anywhere from here,
>    ^ <[d..z]>* $ # match the whole string, containing only letters d
> through z
>   /

That's pretty good! Putting the beginning-of-string anchor ^ anywhere
but the very start is surely an advanced move :)

  - Timo

Reply via email to