Dear Sir
Regular Expression: Not equal to Account and not begin with Account/
How do I express that in a regular expression?
Thank You.
Dear Sir
Regular Expression: Not equal to Account and not begin with Account/
How do I express that in a regular expression?
Thank You.
If your implementation supports look-around assertions, you can do this with a negated look-ahead assertion:
^(?!Account($|/))
The same can be done with a negated look-behind assertion. Otherwise, if you just can use basic syntax, you will probably do something like this:
^($|[^A]|(A($|[^c]|c($|[^c]|c($|[^o]|o($|[^u]|u($|[^n]|n($|[^t]|t[^/]))))))))
But maybe it suffices if you try to match either equal to Account
or begins with Account/
and invert the result of the match.
Imagine the regex (for some regex flavors) /^(Account$|Account\/)/
which only matches "Account" or things that begin with "Account/". Note the use of anchors (^ and $) as appropriate.
Why is the above regex the opposite of the question? In many cases of "not looking for" the outer-regex conditional can (and should) simply be a negation.
This says 'If the line doesn't belong with Account or contain Account (I know redundant) then match the entire line:
(?! ^Account)(?! ^.Account.)^.*$