I have the following Regex:
(?<day>\d+). Tag, (?<way>.+)?( \((?<length>\d+?.?\d?)km\))?
And i want to match these three possibilities:
1. Tag, Berlin -> London (500.3km)
2. Tag, London -> Stockholm (183km)
3. Tag, Stockholm (day of rest)
The problem: It doesn't match the length anymore. If I remove the questionsmarks to this:
(?<day>\d+). Tag, (?<way>.+)( \((?<length>\d+?.?\d?)km\))
It matches the first and second one not the third one. I thought I could solve the problem by adding the question mark at the end. But then the last expression becomes lazy. So I add another question mark to the way-expression but it doesn't become more lazy than the last one. So the way is matching the whole length too!
So, is it possible to define different level of lazyness? And if there this doesn't exist, how should i change the pattern to match it right?
Julian
(day of rest)with(\d+?.?)km. What is the expected output?.+in <way> can match the open bracket character(. Maybe use[^\(]instead?(?<day>\d+)\.\s+Tag,\s+(?<way>.+?)\s+\((?<length>[^()]+)\)is not a solution, right? What is the regex flavor, BTW?