[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [mind game] Seeking for simple task impossible via regexps
- From: Coda Highland <chighland@...>
- Date: Thu, 23 Feb 2017 19:11:36 -0800
On Fri, Feb 24, 2017 at 4:57 AM, Martin <eden_martin_fuhrspam@gmx.de> wrote:
> I didn't know about this regexp language. In what programming languages
> it used (or what is the name of this regexp language itself)?
Perl Compatible Regular Expressions. It's supported by Perl
(obviously), Python, PHP, Javascript, and thanks to libpcre pretty
much any language that can load C libraries.
> Also how /(a.*a|b.*b)/ is treated? (Let's assume two-character alphabet
> {'a', 'b'} and string "abab" for which we shouldn't get a match). At
> first glance this looking like "match('a', any_chars, 'a') or
> match('b', any_chars, 'b')".
Your reading is correct. If either of those conditions are matched,
then there's a duplicate letter in the string somewhere, and therefore
we know we should reject it. It's harder (but not impossible) to get
the inverse behavior, where the regexp matches legal strings and
rejects illegal strings; I believe you'd need a negative-lookahead
assertion.
/s/ Adam