I have an expression like
test_abc_HelloWorld_there could be more here.
- I’d like a regex that takes the first word before the first underscore. So get
"test"
I tried [A-Za-z]{1,}_ but that didn’t work.
- Then I’d like to get “abc” or anything in between the first 2 underscores.
2 Separate Regular expressions, not combined
Any help is very appreciated!
Example:
for 1) the regex would match the word test
for 2) the regex would match the word abc
so any other match for either case would be wrong. As in, if I were to replace what I matched on then I would get something like this:
for case 1) match “test” and replace “test” with “Goat”.
'Goat_abc_HelloWorld_there could be more here'
I don’t want a replace, I just want a match on a word.
In both case you can use assertions.
will get you everything up to the first underscore of the line, and
will match whatever string is located between two unserscores.