MOO-cows Mailing List Archive
[Prev][Index][Thread]
Yet another match error
-
Date: Thu, 17 Aug 1995 08:55:02 PDT
-
From: azuki@ci.uminho.pt
-
Content-Length: 1514
-
Content-Transfer-Encoding: 7bit
-
Content-Type: text/plain; charset=US-ASCII
I don't know if this error was already posted here as I do not read MOO Cows.
If it was, I apologise but nevertheless state that this error is quite serious,
especially to someone like myself who use regular expressions a lot.
;substitute("%1+%2+%3+%4",match("me as A guy in the mood for maths","^%(.+%) +%(in +%([^ ]+%) +%)?as +%(.*%)$"))
=> "me+as A guy in the +t+A guy in the mood for maths"
Now, I thought this was fishy, look at the same in Perl:
$_="me as A guy in the mood for maths";
print "$1+$2+$3+$4" if /^(.+) +(in +([^ ]+) +)?as +(.*)$/;
Result: me+++A guy in the mood for maths
A little strange how %(in +%([^ ]+%) +%)? matched 'as A guy in the ' and the
inner parenthesis matched 't'...
--
|\_/|
|@ @|
,-------------------------vvvV--<o o>--Vvvv---------------------------------.
| Rui Mendes V"V |
| azuki@s700.uminho.pt Any sufficiently advanced technology |
| http://s700.uminho.pt/~azuki is indistinguishable from magic. |
| Finger me for PGP key Arthur C. Clarke |
`---------------------------------------------------------------------------'
$x=<<EOF;$x=~s/./$x{$&}++;$&/ge;%x=map{$_,$c++}sort{$x{$b}<=>$x{$a}}keys%x;$x=~s/./for(1..$x{$&}){vec($v,$n++,1)=1;}$n++;/ge;print$v;
12212224314112411111212111314353112411123221312141111121111142213121411331111121111232111331133232213121411321
EOF
Home |
Subject Index |
Thread Index