Hi
In reference to my query about 'greed' in regex in php and the following
code
$x = ereg("<route name='$to' x='\.\./(.*)/in' rec='.*' />", $get_route, $m);
I solved the immediate problem with the following:
<route name='$to' x='\.\./([a-z]{2}|a?u_[0-9a-z]{8})/in' rec='.*' />
as you can see, the regex is quite a bit more complicated and I
do not know if it will match all the possibilities that it will have to.
It looks like it should. one possibility that it is matching is just two
letters, in this case jk. The other possibility is u_ or  au_ followed
by 8 randomly selected letters and/or numbers.
In short I was trying to be as simple and comprehensive as
possible with (.*) as the regular expression. But the idea of greed
came to mind when the match was containing far more than antic-
ipated. Greed is when the regular expression tries to match as much
as possible, in this case (.*) appears to be matching every instance of
anything and everything else in the way, so it ends up including the
entire balance of the line. A least that is my explanation. So I did
something more complicated to get what I wanted. Simplicity is not
always so simple.
Thanks for all responses.
JK

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to