pietà :
I'm dealing with regular expressions, but I’m not a big fan of it and I’m obliged to deal with it in my task :(
I have passed hours looking for a solution but everytime I fail to cover all scenarios. I have to write a regular expression template that supports these patterns:
DYYU-tx-6.7.9.7_6.1.1.0
DYYU-tx-6.7.9.7_60.11.11.09
DYYU-tx-60.70.90.70_6.1.1.0
I feel that this is very simple to do.. So excuse me if it's a stupid question for someone :(
I tried this pattern but it didn’t work : ^.*_.*-.*-([0-9]*)\\..*\\..* $
Any help please. I will be more than thankful.
mrzasa :
Try this one:
^\w+-\w+-(\d+)(\.\d+)+_(\d+\.)+\d+
In Java most probably sth like this:
"^\\w+-\\w+-(\\d+)(\\.\\d+)+_(\\d+\\.)+\d+"
Explanation:
^\w+-\w+-
first two parts, e.g.DYYU-tx-
(\d+)(\.\d+)+_
numbers separated with.
ending with_
, e.g.6.7.9.7_
(\d+\.)+\d+
numbers separted with.
, e.g.60.11.11.09