KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've just learned about these two concepts in more detail. I've always been good with RegEx, and it seems I've never seen the need for these 2 zero width assertions. I'm pretty sure I'm wrong, but I do not see why these constructs are needed. Consider this example: Match a 'q' which is not followed by a 'u'. 2 strings will be the input: Iraq quit With negative lookahead, the regex looks like this: q(?!u) Without it, it looks like this: q[^u] For the given input, both of these regex give the same results (i.e. matching Iraq but not quit ) (tested with perl). The same idea applies to lookbehinds. Am I missing a crucial feature that makes these assertions more valuable than the classic syntax?
Tags (comma-separated)
Save Edits
Cancel