How to exclude a string using a regular expression

regular expression

I have this file named test:

http://edge.sharethis.com
http://edge.sharethis.com
https://timetosa.com
http://timetosa.com
https://webtest.es
holahttp.com
timetosa

I want a expression that excludes any line that contains timetosa.

This is not allowed : cat test | grep -v timetosa, because I want to use a pure regular expression in another program.

I know it has to do with ^ but cannot get to the right solution, to affect the ones which not include the string timetosa:

cat test | sed 's/^[timetosa]//g' and cat test | sed 's/^(timetosa)//g' without success.

Could anyone help me ¿?

Best Answer

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, nmap could be invoked passing the site which you want it to scan.

    • Applications are configured using the Options Applications screen.

Related Question