[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [mind game] Seeking for simple task impossible via regexps
- From: Coda Highland <chighland@...>
- Date: Thu, 23 Feb 2017 15:44:07 -0800
On Fri, Feb 24, 2017 at 1:29 AM, Martin <firstname.lastname@example.org> wrote:
> Hello all!
> I'm seeking for simply formulated and easy-coding string matching
> task which is impossible to solve via currently existing regular
> expressions handlers.
> (Indeed I'm seeking for a complete definition of task classes that
> regexps can't handle in principle.)
> For example:
> Check that given string in lowercase contains no more than one entry
> of alphabet character.
> (so all permutations of subset of alphabet [a-z] should be matched)
Not hard at all. If you support backreferences in pattern strings
(common feature) then it's just /([a-z]).*\1/. If you don't, then it's
more verbose, but it's just /(a.*a|b.*b|c.*c| --(snip)-- |y.*y|z.*z)/.
> Another example:
> Check that given string in lowercase contains all symbols of
> predefined alphabet. Ignore spaces.
> (so "the quick brown fox jumps over the lazy dog" should match)
Also quite tractable, using lookahead: /(?=.*a)(?=.*b) --(snip)-- (?=.*z)/.
> My bet is that no existing regexp facilities may handle this
> tasks. But maybe some of them can, so asking.
> (I assume that calling user-supplied function from regexp handler
> is not allowed. Or else this is trivially solved by Lua's gsub().)
> -- Martin