in reply to Re: The "anchor" misnomer in regexes
in thread The "anchor" misnomer in regexes
Those aren't identical.
You're still thinking of $ as a starting point versus simply being a zero-width assertion. /#([^#]*)$/ is the one that reverses to /^(.*?)#/. The original regex /#(.*?)$/ is more clearly written as /#(.*)$/. Because you don't have any non-zero-width assertions between the .*? and the $, the non-greedy modifier doesn't actually change any behavior. The reverse of the original is /^(.*)#/ - explicitly greedy.$string = "abc#def#ghi"; ($x) = $string =~ /#(.*?)$/; print "$x\n"; ($x) = reverse($string) =~ /^(.*?)#/; $x = reverse $x; print "$x\n"; ---- def#ghi ghi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: The "anchor" misnomer in regexes
by eric256 (Parson) on Dec 18, 2005 at 01:56 UTC |