.net - Unifying lookahead and lookbehind into a single regex operator -
i making simplified/sugary wrapper regex cuts out many of more complicated regex functions (whilst still keeping essentials 99% of uses), , tries tidy syntax little.
in regards negative lookahead/lookbehind, found confusing why can't combined single function. clarify mean, let me demonstrate example:
i know use negative lookbehind if don't want match "mo" if it's preceded "giz". expression (?<!giz)mo handle that.
and know use negative lookahead if don't want match "giz" part if it's followed "mo". expression giz(?!mo) handle that.
what don't know why regex can't figure out itself. in theory, shouldn't need specify whether it's ahead or behind - should @ disallowed bit, , exclude expression contains that.
to further clarify, , maybe prove point, might sugary wrapper interpret own custom-purpose symbols - ⊄ , ⊅ - this:
...replace this: giz⊄mo⊅ this: giz(?!mo)(?<!mo)
...and replace this: ⊄giz⊅mo this: (?!giz)(?<!giz)mo
as can see, in both instances, it's using both lookahead , lookbehind, user doesn't have decide 1 use. may user being lazy, can regex being lazy not doing behind scenes.
to restate question in yet way, practical things can (?!xyz) and/or (?<!xyz) can't single: (?!xyz)(?<!xyz)? why regex need 2 operators apparently perform functionality of one?
i'm using .net lookbehind has full versatility.
am missing something?
a simple example of might want (?!xyz), not (?!xyz)(?<!xyz), in regex xyz(?!xyz), match xyz not followed xyz. try xyz(?!xyz)(?<!xyz) , see never matches: point (?<!xyz) checked preceded xyz, because matched that.
Comments
Post a Comment