I tried to use regular expression (php) to match ending Roman Numerals. For simplicity, consider example below:
$str="Olympic III";
preg_match("#^(.*)(III|II|I)$#",$str,$rep);
print_r($rep);
That will only matches a single "I". The correct answer is for me to use ungreedy "U" modifier. But why? Doesn't regular expression use the order I provided (try "III" first before try "II" or "I")?
No comments:
Post a Comment