I am trying to create a regex to parse specific string .
The current string is abcd_1.263.0.15-8zz00df.yml
and I want to parse only 1.263.0.15-8zz00df
out of it.
Tried already with this expression "_\K.*(?=\.)"
but its not working in Golan and giving me pattern error. Can someone please help with this?
Go uses RE2 regex engine, that does not support lookaheads, lookbehinds and other PCRE goodies like \K
See this comparison of the different regex engines.
You could however use this regex:
[^_-]+-[^.]+
See this demo.
Explained:
[^_-]+ # a character that is not "_" or "-", one or more times
- # a literal "-"
[^.]+ # a character that is not a dot, one or more times