Can someone provide me with a regular expression that will find this string : <% but will exclude this string : <%@ Thanks.
If you're using .NET, the regular expression you're looking for is:
<%(?!@)
It will also work in non-.NET applications, but some regular expression implementations don't support (?!)
The exact correct answer varies between different regex syntaxes, but something like this should work:
<%[^@]
or perhaps this, if your regex syntax allows:
<%([^@]|$)
The latter will also match an occurrence of <% at the end of the string (or line), whereas the first regex probably won't.
Finally, as other posters suggest, this might work too if your regex language has "zero-width negative look-ahead assertions" (like Perl and C#):
<%(?!@)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With