[Cialug] RegEx

Jeff Davis jeff at dynamictelecard.com
Wed Oct 12 15:54:33 CDT 2005



Aaron Porter wrote:
> On 10/12/05, *Tim Wilson* <tim_linux at wilson-home.com 
> <mailto:tim_linux at wilson-home.com>> wrote:
> 
>     Sorry, don't know PHP, but I'm becoming more educated on regular
>     expressions.  Try this:
> 
>     sed -e 's/<st1.*>\(.*\)<\/st1.*>/\1/' <foo.xml >foo.txt
> 
> 
> Or  perl...
> $string  =~ s/<st1(.*)>(.*)<st1(.*)>/$2/sm;

That should probably be:
$string  =~ s/<st1(.*)>(.*)<\/st1(.*)>/$2/sm;


I'd probably just do:
     $line =~ s/<\/?st1:(.*\s?.*?):st=\"on\">//;
Using .* a lot can get ugly and doesn't include whitespace.


I think that would translate to PHP as:
  ereg_replace('<\/?st1:(.*\s?.*?):st=\"on\">', '', $string);


More information about the Cialug mailing list