in reply to Re: Dictionary filter regex
in thread Dictionary filter regex

I second your approach to break up the logic into 3 regexes, but

> Mushing this into a single regular expression is possible, by using [^sh] instead of dot

Do you mean   /s[^sh]*h/i ?

I doubt this, you would also need to check all characters before and after the match

  /^ [^sh]* s [^sh]* h [^sh]* $/xi *

Otherwise something like "h--<s--h>--s" should match in the middle. (Untested)

I think this demonstrates well why stuffing all logic into one regex is not always a good idea, particularly inversion isn't trivial.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

footnotes

*) I just saw that tybalt89++ already posted this regex in this thread.

Replies are listed 'Best First'.
Re^3: Dictionary filter regex
by Corion (Patriarch) on Nov 26, 2016 at 19:25 UTC

    Yes - my post would have been much clearer had I also included the anchors and the (then explicit) .* before and after the matches.

    Thank you for pointing this out and making it explicit!