LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   regular expressions negation (https://www.linuxquestions.org/questions/programming-9/regular-expressions-negation-764367/)

wakatana 10-25-2009 02:04 PM

regular expressions negation
 
Hi All,
I am wondering If is possible to write more complcated regexp such this:

lets say I have file
Code:

"datum">Sobota 24. októbra 2009
and I want everthing within quotes ("datum") so i write
Code:

grep -oE '"[^"]*"'
which works fine.

And now, what if I want everything that is not in the quotes? (>Sobota 24. októbra 2009)

I tried negation of previous regexp
Code:

grep -oE '[^("[^"]*")]*'
but gives me error:
grep: Unmatched ) or \)

Is possible to write negation of regular expression?

Thank you for reply

tuxdev 10-25-2009 02:43 PM

Use the -v flag to inverse grep's results. But, maybe you want to use sed to delete matched text?

wakatana 10-26-2009 04:49 AM

Hi,
yes I knew -v option (also with -o is interesting) but was interested if it is possible doing more comlicated regexp, but probably -v is the best solution. Thank you


All times are GMT -5. The time now is 07:04 AM.