Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-25-2009, 02:04 PM   #1
Registered: Jul 2009
Location: Slovakia
Posts: 133

Rep: Reputation: 16
regular expressions negation

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

lets say I have file
"datum">Sobota 24. októbra 2009
and I want everthing within quotes ("datum") so i write
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
grep -oE '[^("[^"]*")]*'
but gives me error:
grep: Unmatched ) or \)

Is possible to write negation of regular expression?

Thank you for reply
Old 10-25-2009, 02:43 PM   #2
Senior Member
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

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

Last edited by tuxdev; 10-25-2009 at 02:45 PM.
Old 10-26-2009, 04:49 AM   #3
Registered: Jul 2009
Location: Slovakia
Posts: 133

Original Poster
Rep: Reputation: 16
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


expressions, grep, regexp, regular

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions ziggy25 Linux - Newbie 7 11-05-2007 06:57 AM
regular expressions. stomach Linux - Software 1 02-10-2006 06:41 AM
help with REGULAR EXPRESSIONS ner Linux - General 23 10-31-2003 11:09 PM
Regular expressions aromes Linux - General 1 10-15-2003 12:29 PM
regular expressions? alaios Linux - General 2 06-11-2003 03:51 PM

All times are GMT -5. The time now is 08:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration