Hi
Normally I don't have problems with regex but I think I misunderstand the "shortest match" = ? operator.
Let's say you have a string:
1-2-3-4|5
And I want to extract "4".
I though it's easy: "-" is before 4 and "|" after 4 ... and then you"ll get 4 if you use the shortest match operator. So:
(?<=-).*?(?=\|)
Though, this doesn't extract "4", but "2-3-4", which means .*? doesn't extract the shortest match(since "4" and even "3-4" would be shorter)...although it should.? (unless I misinterpret the ? operator).
Is this a bug or is my regex wrong?
Thanks.
Normally I don't have problems with regex but I think I misunderstand the "shortest match" = ? operator.
Let's say you have a string:
1-2-3-4|5
And I want to extract "4".
I though it's easy: "-" is before 4 and "|" after 4 ... and then you"ll get 4 if you use the shortest match operator. So:
(?<=-).*?(?=\|)
Though, this doesn't extract "4", but "2-3-4", which means .*? doesn't extract the shortest match(since "4" and even "3-4" would be shorter)...although it should.? (unless I misinterpret the ? operator).
Is this a bug or is my regex wrong?
Thanks.