c# - Regex - find matches not contained within pattern -
i use regular expression match occurrences of phrase it's not contained within delimiting characters. tried putting 1 had difficulty negative lookaheads.
my search phrase "my phrase". start delimiter tag [[ , end delimiter tag ]]. string i'd search is:
here sentence my phrase, here's part don't want match on [[my phrase]]. find occurrence of my phrase.
from string expect find occurrences of "my phrase" except 1 contained within [[ ]].
i hope makes sense, in advance guidance.
[^#]my phrase[^#]
i have knocked regex ask, can seen here.
literally escaping out # character , allowing other character returned. can return index of these results remember strip off first , last character of string.
note: not pick "my phrase" end sentence without character following it
edit - seeing changed scope while writing answer, here regex other delimiter:
[^[[]my phrase[^\]\]]
Comments
Post a Comment