Regular expression to find from start of string to first space

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

 



PHP,

Shouldn't this regular expression select everything from the start of the string to the first space character:

$firstWord = preg_match('#^*(.*) #iU', $word);

It doesn't, so clearly I'm wrong, but here's why I thought it would:

The enclosing has marks, "#", I *think* just encloses the expression. I was told to use them before, but I can't find them here:
http://jp2.php.net/manual/en/reference.pcre.pattern.syntax.php

The caret, "^", says to start at the beginning of the line.

The first asterix, "*" after the caret says to use any starting character.

The space just before the second "#" is the closing character of my search.

The "(.*)" in the middle says to take anything in between the beginning of the line and the space.

"iU" says, "be case insensitive, and don't be greedy".

So, it should start at the beginning of the line and get everything up to the first space. But it doesn't work.

Where did I go wrong?

--
Dave M G

--
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