lua-users home
lua-l archive

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


On Wed, 26 Jan 2011, Tim Mensch wrote:
>
> > %bxy, where x and y are two distinct characters; such item matches
> > strings that start with x, end with y, and where the x and y are
> > balanced.
>
> I hadn't run across that before, and it's cool. As Tony mentions, Perl
> has a LOT of extensions, and I don't care enough to check, but I
> wouldn't be surprised if it does support something similar.

You have to do it using explicit recursion, e.g. the (?0) syntax or the
(??{ code }) syntax.

http://perldoc.perl.org/perlre.html#%28??{-code-}%29

> But as far as I'm concerned, what "grep" accepts is the canonical
> "regular expression", and I'm sure grep doesn't support that. Another
> reason why Lua is just more awesome. ;)

I prefer egrep syntax because they have fewer backslashes.

Also, POSIC BREs (grep style) are not proper reegular expressions because
they don't have an alternation operator and they have a backref operator.
POSIX EREs (egrep style) are proper regular expressions in the
mathematical sense.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.