lua-users home
lua-l archive

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

On Fri, Feb 24, 2017 at 4:57 AM, Martin <> 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

/s/ Adam