I would like to write regexp in Go to match a string only if it does not contain a specific substring (-numinput) and contain another specific string (-setup).
Example, for inputStr
The following type of strings should NOT match because -numinput is present
str = "axxx yy -setup abc -numinput 12345678 aaa"
The following type of strings should match as -setup is present and -numinput is not present
str = "axxx yy -setup abc aaa"
The following type of strings should not match because -setup is not present even though -numinput is not present
str = "axxx yy abc aaa"
I came across some posts like Regular expression to match a line that doesn't contain a word?
But, I just dont understand how to do it in Golang
If you want to parse command line flags, consider using the flag package
For general string related functionality, considers the strings package
https://golang.org/pkg/strings/
In your case:
strings.Contains(str, "-setup") && !strings.Contains(str, "-numinput")