On Aug 8, 2006, at 11:30 PM, Dave M G wrote:

PHP List,

This regular expression stuff is way tricky.

Thanks to help from this list, I have an expression that will select the first word of a string, up to the first white space:
"#^(.*)\s#iU"

But after some consideration, I realized that I wanted to keep both parts of the original text. The first word, and then everything that came after it, should be divided and stored in separate variables.

Now, I would do this different. Probably "wrong" but instead of a regular expression here, I would do something like this:

$array = explode(" ",$string);
$first_word = $array[0];
$rest_words = substr_replace($string,"",0,strlen($first_word));

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326

Reply via email to