Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-02-2011
Registered User
 

Join Date: Jul 2008
Location: Texas
Posts: 150
Thanks: 1
Thanked 1 Time in 1 Post
How to do equivalent of /(regexp){0}/ ?

I don't want to have to resort to

Code:
 
/([^s][^t][^r][^i][^n][^g])/

though that does work.

Effectively, I need to be able to implement

Code:
 
/(?:(?:regexp1){0}[^-0-9])(regexp2)\D/

to basically match regexp2 as long as it is present and regexp1 is NOT.

So, how to do

Code:
 
/(regexp){0}/

?
Sponsored Links
    #2  
Old 08-03-2011
pludi's Avatar
pludi pludi is offline Forum Staff  
Cat herder
 

Join Date: Dec 2008
Location: Vienna, Austria, Earth
Posts: 5,486
Thanks: 38
Thanked 324 Times in 301 Posts
You need a zero-width negative look-behind assertion from the extended patterns. Example:
Code:
$ cat /tmp/test.txt
This should be matched.
This should not be matched.
$ perl -ne 'print if /(?<!not\s)be/;' /tmp/test.txt
This should be matched.
$

The Following User Says Thank You to pludi For This Useful Post:
Vi-Curious (08-03-2011)
Sponsored Links
    #3  
Old 08-03-2011
Registered User
 

Join Date: Jul 2008
Location: Texas
Posts: 150
Thanks: 1
Thanked 1 Time in 1 Post
That's what I get for not reading the entire perlre doc.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regexp tip Dedalus Shell Programming and Scripting 3 09-23-2010 02:09 PM
sed regexp King Nothing Shell Programming and Scripting 4 12-18-2009 06:34 AM
print the line immediately after a regexp; but regexp is a sentence ownins UNIX for Dummies Questions & Answers 3 11-16-2008 01:30 AM
regexp help TinCanFury Shell Programming and Scripting 0 04-06-2008 06:21 PM
regexp penfold UNIX for Advanced & Expert Users 1 06-28-2005 07:45 AM



All times are GMT -4. The time now is 04:24 AM.