I have a string that could have a -name followed by value (that can have spaces) and there could also be -descr after that followed by a value (the -descr followed by value may nor may not be there):
Example strings:
runcmd -name abcd xyz -descr abc def
or
runcmd -name abcd xyz
With Go language, how do I write regexp, that returns me the string before -descr if it exists. so, for both examples above, the result should be:
runcmd -name abcd xyz
I was trying:
regexp.MustCompile(`(-name ).+?=-descr`)
But, that did not return any match. I wanted to know the correct regexp to get the string up until -descr if it exists