LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-25-2009, 02:04 PM   #1
wakatana
Member
 
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
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
 
Old 10-25-2009, 02:43 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 110Reputation: 110
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
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 133

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


Reply

Tags
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 09:22 PM.

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