You have to use a negative lookahead assertion.
(?!^ABC$)
You could for example use the following.
(?!^ABC
)
If this does not work in your editor, try this. It is tested to work in ruby and javascript:
^((?!ABC).)*$
Answer from Daniel Brückner on Stack OverflowYou have to use a negative lookahead assertion.
(?!^ABC$)
You could for example use the following.
(?!^ABC
)
If this does not work in your editor, try this. It is tested to work in ruby and javascript:
^((?!ABC).)*$
In .NET you can use grouping to your advantage like this:
http://regexhero.net/tester/?id=65b32601-2326-4ece-912b-6dcefd883f31
You'll notice that:
(ABC)|(.)
Will grab everything except ABC in the 2nd group. Parenthesis surround each group. So (ABC) is group 1 and (.) is group 2.
So you just grab the 2nd group like this in a replace:
$2
Or in .NET look at the Groups collection inside the Regex class for a little more control.
You should be able to do something similar in most other regex implementations as well.
UPDATE: I found a much faster way to do this here: http://regexhero.net/tester/?id=997ce4a2-878c-41f2-9d28-34e0c5080e03
It still uses grouping (I can't find a way that doesn't use grouping). But this method is over 10X faster than the first.
Im sorry but I have basically no knowledge of regex so this may be something easy to answer but I can NOT figure it out.
Im using a program called GINA that reads log files of a game. I'm trying to figure out how to trigger based on this string of text
{S} tells you, '{S1}
(Soandso tells you, "Hello")
But I need it to exclude any string containing the word "Master."
(Yourpet tells you, "Attacking creature Master.")
Help with regex, exclude strings
sed - How can I exclude a string using a regular expression? - Unix & Linux Stack Exchange
REGEX for Strings that have a Certain String, but Exclude those that have a Certain string Prior
Regex multiple include/exclude string from single regex
sed '/timetosa/d' <test
...will do it. Alternatively:
sed -n '/timetosa/!p' <test
Still, though (whether it's allowed or not):
grep -v timetosa <test
...is going to be the most performant solution of the three - and probably by a significant margin.
Thanks to @Sparhawk, I found my way to the zaproxy documentation. Based on this:
- URL regexs
- In the Include in *, Exclude from * panels and the Logged in/out indicators of the Authentication panel, you can enter regular expressions to define excluded URLs.
...and the following, I would guess you're trying to filter Contexts? According to the docs, you can do both include and exclude lists:
- Exclude from context
- This allows you to manage the URLs which will be excluded from the context.
- You only need to specify regexs for URLs that you do not want to include but which match one or more of the include regexes.
So you can exclude some of your previous inclusions.
Still, though, it may be the first bit of this is not entirely irrelevant - the docs also mention this in the Add-ons section:
Invoke Applications
- Other applications can be invoked passing in context information, such as the URL of the message selected.
So, for example,
nmapcould be invoked passing the site which you want it to scan.Applications are configured using the Options Applications screen.
Regular languages are closed under complementation, so for every regular expression, there exists a regular expression that matches exactly the inputs that the original regexp doesn't match.
However, in the worst case, the smallest regexp that matches the complement language has a length that is exponential in the length of the original regexp. So while the regexp is guaranteed to exist, it is not guaranteed to be simple. It can be calculated algorithmically if you really need it.
The ^ operator to anchor a regexp isn't relevant. You may be thinking of ^ in a character set, as in [^a-z] meaning “any one character that isn't a lowercase letter”. This is just part of the shortcut notation for character sets, it isn't helpful to complement a set of strings.
Some regular expression engines, such as perl's or the compatible nd widely-used PCRE, support additional operators beyond the traditional ones including lookaround assertions. A negative lookahead assertion provides a simple way to negate a regular expression without having to break it down into parts. Check the documentation of your software to see what kind of regular expressions it supports.
^(?!.*timetosa)
Or in vim:
^(.*timetosa)\@!
Most systems don't need regexp complementation because you can achieve the same effect by using a matching inversion flag (e.g. grep -v) or by ordering rules carefully in a first-match setting (if it matches .*timetosa.* then do nothing and stop matching rules; if it matches .* then do something).