* Roland Mainz <[email protected]> [2011-04-19 18:48]: > On Tue, Apr 19, 2011 at 5:15 PM, Guido Berhoerster > <[email protected]> wrote: > > why do regex backslash sequences not work inside a charcter > > class? > > E.g. > > [[ "123" == ~(E)[\d] ]] && print match > > does not match, in Perl it does, ie. > > perl -e '"123" =~ /[\d]/ && print "match\n"' > > matches as expected. > > Erm... it seems to work for ast-ksh.2011-02-08 for both egrep and perl > regex mode: > -- snip -- > $./build_normal/arch/linux.i386/bin/ksh -c '[[ "123" == ~(E)[\d] ]] && > print match' > match > $ ./build_normal/arch/linux.i386/bin/ksh -c '[[ "123" == ~(P)[\d] ]] > && print match' > match > -- snip --
OK, I've only tried on older versions. Version JM 93t+ 2010-03-05 on OI b148/Illumos: $ [[ "123" == ~(E)[\d] ]] && print match $ [[ "123" == ~(E)\d ]] && print match match $ [[ "123" == ~(P)[\d] ]] && print match $ [[ "123" == ~(P)\d ]] && print match and Version JM 93t+ 2010-06-21 on openSUSE 11.4: $ [[ "123" == ~(E)[\d] ]] && print match $ [[ "123" == ~(E)\d ]] && print match match $ [[ "123" == ~(P)[\d] ]] && print match match $ [[ "123" == ~(P)\d ]] && print match match > Note that perl5 uses a traditional NFA engine (this should be > ~(P)pattern) while ksh93 uses a POSIX NFA engine (e.g. ~(E)pattern)... > there are subtle differences like that a traditional NFA engine > matches the first match in an "or" expression like (a|aaa) while POSIX > NFA engines always match the longest match (libast's perl regex mode > doesn't do this... erm... Glenn ?). So at least on ksh93t it seems inconsistent. The "P" modifier is also (in contrast to the backslash sequences) not documented in the manpage and seems to behave differently on Illumos/SX11 and Linux. -- Guido Berhoerster _______________________________________________ ast-users mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-users
