The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need a regular expression tony3101 Shell Programming and Scripting 4 06-05-2008 12:13 AM
regular expression jaber87 Shell Programming and Scripting 3 06-05-2008 12:07 AM
regular expression and awk nickg UNIX for Dummies Questions & Answers 2 08-16-2007 02:23 PM
regular expression...help!! andy2000 UNIX for Dummies Questions & Answers 6 07-18-2007 02:10 PM
Regular Expression + Aritmetical Expression Z0mby Shell Programming and Scripting 2 05-21-2002 07:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-22-2006
Rakesh Ranjan's Avatar
Registered User
 

Join Date: Aug 2005
Location: India
Posts: 40
Question help in regular expression

Hi all,
I'm working with flex (version 2.5.4a) on GNU/linux. I need to frame a regular expression which would match cases where word "file" does not occur. Negated character class wont work for me because they enforce "or" clause between different chars (so something like [^file] wont work). I would like to avoid an explicit expansion.
I hope I'm clear enough. I know this would be pretty simple for few but your help would really be appreciated.
Reply With Quote
Forum Sponsor
  #2  
Old 10-23-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,274
Code:
[^f][^i][^l][^e]
overcomes your objection.
Reply With Quote
  #3  
Old 10-24-2006
Rakesh Ranjan's Avatar
Registered User
 

Join Date: Aug 2005
Location: India
Posts: 40
Still not solved

I'm really sorry if i was not clear enough but this is not the solution for what I wanted. I want the reg. exp. to match all patterns except "file".
Code:
PDL:
while (!end of input stream){
read (input);
if (input!="file")
print("required pattern");
else
print("I don't want this pattern");
}
That is anything except word "file".
An expansion for it could be of the form of
[^f]ile|f[^i]le|fi[^l]e|fil[^e]|[^f][^i]le.....and so on (can't really write full expression for it will have 2^4=16 combinations combined together).
I'm really thankful, you gave your time and hope you (or anyone else) will help me with the solution.
Reply With Quote
  #4  
Old 10-24-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,274
I'm really not getting what you want - lex allows rules of the form r{m,n}
create a simple regex of '^.*file.*$' and apply a r{0,0} to it. Set r{0,0} which means your "file" regex can only occur in the string zero times.... ?
Reply With Quote
  #5  
Old 10-24-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
That is anything except word "file".
An expansion for it could be of the form of
i really dont know,

is it as simple as grep -v "file" <filename> ? i dont get that really

can you please provide some samples ?
Reply With Quote
  #6  
Old 10-25-2006
Rakesh Ranjan's Avatar
Registered User
 

Join Date: Aug 2005
Location: India
Posts: 40
Ok jim i'll check out if this suits me. And yes matrix if you meant inverting the selection by 'grep -v' then you are right (but then I've to use lex/flex).
Meanwhile I'm stuck up with another problem I've posted it as new post as its not relevant to this thread. But I'ld like to request you both to look into the problem and help me out.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0