LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   php preg_replace and perl regex matching (https://www.linuxquestions.org/questions/programming-9/php-preg_replace-and-perl-regex-matching-730146/)

aolong 06-02-2009 09:33 AM

php preg_replace and perl regex matching
 
I'm having trouble with this one...

I need to replace everything from beginning of string up to the first occurrence of "= Gauge32: " OR "=STRING: " with "".

$output = shell_exec("./script.sh $propertyIP");
$pattern = 'the expression I can't seem to write';
$replace = '';

echo "<pre>" . preg_replace($pattern,$replace,$output) . "</pre>";

clues?

jan61 06-02-2009 05:32 PM

Moin,

Quote:

Originally Posted by aolong (Post 3560371)
I'm having trouble with this one...

I need to replace everything from beginning of string up to the first occurrence of "= Gauge32: " OR "=STRING: " with "".

$output = shell_exec("./script.sh $propertyIP");
$pattern = 'the expression I can't seem to write';
$replace = '';

echo "<pre>" . preg_replace($pattern,$replace,$output) . "</pre>";

clues?

strange pattern ;-) Try this (untested):
Code:

$pattern = '.*(= Gauge32: )|(=STRING: )';
Jan


All times are GMT -5. The time now is 02:24 PM.