LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-02-2009, 09:33 AM   #1
aolong
Member
 
Registered: Aug 2006
Location: US
Distribution: Debian, CentOS
Posts: 40

Rep: Reputation: 15
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?
 
Old 06-02-2009, 05:32 PM   #2
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 46
Moin,

Quote:
Originally Posted by aolong View Post
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

Last edited by jan61; 06-02-2009 at 05:34 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl only matching single-character regex patterns? Lordandmaker Programming 3 01-20-2009 08:59 AM
Matching two wildcards with perl and regex borinus Programming 3 09-09-2008 04:04 AM
Embedded regex matching in Perl GATTACA Programming 5 01-17-2007 09:16 AM
regex matching things like , etc. aunquarra Programming 2 05-04-2005 07:53 AM
perl regex matching exodist Programming 2 11-15-2004 10:50 PM


All times are GMT -5. The time now is 04:32 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration