Re: preg_match fails to resolve variable as a subject

From: Date: Sat, 27 Nov 2010 03:51:59 +0000
Subject: Re: preg_match fails to resolve variable as a subject
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-309695@lists.php.net to get a copy of this message
On Nov 26, 2010, at 7:28 PM, Da Rock wrote:
On 11/27/10 00:57, Richard Quadling wrote:
On 26 November 2010 00:07, Da Rock<php-list@herveybayaustralia.com.au> wrote:
preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command),&$matches)
Can you ... var_dump(exec($mixer . ' ' . $command)); I wonder if the output includes a new line which you are not accounting for in the regex.
Haven't tried yet, but isn't that what $ is for? End of line?
$ matches end of line, but since your last match expression is to match explicitly the character '.' before end of line, and there's a newline, it won't match. Again, use trim() to get rid of the newline character at the end of the string returned by exec(). Looking at the output or
And exec only gives one line- the last line of the output of the command. You have to provide a reference to an array for the entire output. var_dump gives: string(41) "Mixer vol is currently set to 75:75"
It also looks like \d{1,3}\. won't match anything in the output string given by the command.

« previous php.general (#309695) next »