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.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-04-2012
Registered User
 

Join Date: May 2011
Posts: 63
Thanks: 12
Thanked 0 Times in 0 Posts
finding first >

I want to erase some php code between a <? and a ?> in HTML containing a keyword, the problem is it finds the last > and wipes out everything before it

how do i specify for it to stop searching after the first >?




Code:
perl -i -p0e 's/<\?php.*keyword.*\?>//s'

there's many lines of php code in the document so what this does is erases until the last > but i dont want it to go that far

thanks!
Sponsored Links
    #2  
Old 02-04-2012
bartus11's Avatar
Registered User
 

Join Date: Apr 2009
Posts: 2,654
Thanks: 3
Thanked 789 Times in 777 Posts

Code:
perl -i -p0e 's/<\?php.*?keyword.*?\?>//s'

It is called "non-greedy" matching.
Sponsored Links
    #3  
Old 02-04-2012
Registered User
 

Join Date: May 2011
Posts: 63
Thanks: 12
Thanked 0 Times in 0 Posts
thanks for the quick response!
Sponsored Links
Reply

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
Finding my DNS jjinno UNIX for Dummies Questions & Answers 2 07-17-2007 09:14 AM
finding duplicate files by size and finding pattern matching and its count jerome Sukumar Shell Programming and Scripting 2 12-01-2006 03:20 AM
Help finding a BOS zuessh AIX 1 07-25-2006 02:48 AM
Finding last row indo1144 UNIX for Advanced & Expert Users 7 09-23-2005 03:25 AM
Finding how done IT geoquest UNIX for Dummies Questions & Answers 5 08-26-2002 10:12 AM



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