How can I match a text with colon using regex?
Question:
I want to use regex to match any case with only 1 colon in front of a name or behind it, but not a name in between two colons.
Matches things like this:
name: | :name | name:`asdf`
But should not match any of these:
:name:
eman:
nnamee:
:nameasdfj
I have a regex that I think covers all cases for the first three, but it also matches :name: which I don’t want:
((?:^|W)name:(?:$|W))|((?:^|W):name(?:$|W))
Answers:
I want to use regex to match any case with only 1 colon in front of a name or behind it, but not a name in between two colons.
Matches things like this:
name: | :name | name:`asdf`
But should not match any of these:
:name:
eman:
nnamee:
:nameasdfj
I have a regex that I think covers all cases for the first three, but it also matches :name: which I don’t want:
((?:^|W)name:(?:$|W))|((?:^|W):name(?:$|W))