Reputation: 19682
At first I thought this must be very easy, I am just overlooking something, but so far with my limited knowledge of regex I can't figure this out,
I have a regex like [some characters]MYNAME
actual thing is:
rx = rx + `[ ,\t,,\,,\(,=,@,\s]+(MYNAME)`
I want this regex to also detect a line that starts with MYNAME
.
So the question is, is there a way to add ^
inside []
with other things? or to OR
the ^
with a [some characters]
?
I can't make it work either with javascript or golang. If there are differences related to this matter, I am interested in the golang specific solutions.
Upvotes: 1
Views: 134
Reputation: 213261
You can use alternation. Also, there are some unnecessary characters in your character class:
(
in a character class. \s
, you don't need to add \t
and " "
separately.So, your regex can be simplified to:
"(?:[(=@\s]+|^)(MYNAME)"
Upvotes: 4