c# - Negative lookahead of an odd number `\` before the requested letter -
how can 1 find letters a
of string condition there no odd number of \
directly in front of it.
to 1 \
be
@"(?<!\\)a"
which works quiet well. how odd numbers of \
excluded?
for instance
a
,\\a
,\\\\a
, ... should allowed\a
,\\\a
,\\\\\a
, ... should neglected
ps. nice if c# class system.text.regularexpressions.regex
handle result.
you can use following:
(?<!\\)(?:\\\\)*a
see demo
explanation:
(?<!\\)
lookbehind no\
(to avoid matching\
's between)(?:\\\\)*
match 0 or more of double slashes\\
(escaped\
each..) match number of\
'sa
match literala
Comments
Post a Comment