I'd like to ask another regex question. Consider this string:
$x = 'ab cd cd EF ghi jkl'; $x =~ /cd (.*) ghi/;$1 evaluates to "cd EF". This looks correct.
But:
$x =~ /cd (.*?) ghi/;$1 evaluates to "cd EF", same as above. A strange result, as I expect it to be just "EF".
Why do matches aginst (.*) and (.*?) result in exactly the same result? What needs to be done to get only the "EF" as a result?
In real life the EF is a random text that I want to extract.
Thank you.
In reply to Regex problem - (non)greedy? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |