Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

regular expressions

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
tedius



Joined: Fri Apr 08, 2005 4:20 pm
Posts: 83
Location: Cambridge, England

PostPosted: Mon Feb 12, 2007 9:46 am    Post subject: regular expressions Reply with quote

I have a structure with a member secno and I want to find all the files where a secno comparison is made. So I though that a egrep would do the job nicely, and I came up with this.

egrep ".*secno == .*secno.*" *.cc

Now I had run this command multiple times, changing the comparison function each time, i.e. ==, >, <, <=, >= and !=

Does anyone know if there is way I could have done all this with one regular expression rather than the 6 that I came up with.

Thanks
Back to top
View user's profile Send private message MSN Messenger
MartyBartfast
LXF regular


Joined: Mon Aug 22, 2005 8:25 am
Posts: 814
Location: Hants, UK

PostPosted: Mon Feb 12, 2007 11:20 am    Post subject: RE: regular expressions Reply with quote

I think this will do what you want:

egrep ".*secno [=<>\!]=? .*secno.*" *.cc
Back to top
View user's profile Send private message
tedius



Joined: Fri Apr 08, 2005 4:20 pm
Posts: 83
Location: Cambridge, England

PostPosted: Mon Feb 12, 2007 11:28 am    Post subject: RE: regular expressions Reply with quote

That Marty,

No that was my first attempt too, but that will also give you assignment.

I've now found a way though

egrep "secno (==|(<|>|\!)=?) .*secno" *.cc
Back to top
View user's profile Send private message MSN Messenger
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast