Re: preg_match fails to resolve variable as a subject

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxxxxxxxxxxxxxxxxx> 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.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux