I have a String as vsc-nigulp-25.00.00-200.tar , I have to get two set of outputs as vsc-nigulp and 25.00.00-200 from the given string. What Regex conditions would be giving these two set of outputs?
Asked
Active
Viewed 37 times
-4
-
2What language (if any) are you using? What have you tried so far? – Tim Biegeleisen Dec 06 '18 at 13:45
-
1The `vsc-nigulp` regex would match the first part you wish to retrieve, while the `25\.00\.00-200` regex would match the second (we need more than a single sample of your input to give a meaningful answer). Will your versionning scheme always follow the `xx.xx.xx-xxx` format? – Aaron Dec 06 '18 at 13:47
-
I have to pass these values to ansible , I have tried using https://regex101.com/r/8BDmFj/1 – Sitharthan Anbazhakan Dec 06 '18 at 13:48
-
@Aaron yes xx.xx.xx-xxx this will follow the same pattern – Sitharthan Anbazhakan Dec 06 '18 at 13:51
-
I don't know ansible, but check if it can use back-references / refer to capturing groups, and use the following pattern : https://regex101.com/r/8BDmFj/2 – Aaron Dec 06 '18 at 13:56
-
Thanks @Aaron I am able find the solutions – Sitharthan Anbazhakan Dec 06 '18 at 14:19
1 Answers
1
How about:
(^[a-zA-Z-]*)(\d{2}.\d{2}.\d{2}-\d{3})
- Beginning of text, any number of letters or dashes
- Followed by your pattern of numbers and dashes

tk78
- 937
- 7
- 14