Re: [PHP] Dividing, and keeping, text from the first space

2006-08-10 Thread Richard Lynch
On Wed, August 9, 2006 1:30 am, Dave M G wrote: 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

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-10 Thread Richard Lynch
On Wed, August 9, 2006 5:07 am, Dave M G wrote: The brackets indicate a sub-expression. The parens indicate that you want to CAPTURE the matched characters. Inside of [ ] the parens would be a sub-expression, however. First question, why is there an extra backslash before the space marker

[PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Dave M G
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.

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 15:30 +0900, 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

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 02:57 -0400, Robert Cummings wrote: On Wed, 2006-08-09 at 15:30 +0900, 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

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Dave M G
Robert, Thank you for your quick response and helpful advice. Use preg_match() and pay special attention to the manual as it refers to the third parameter :) The expression you need follows: #^([^\\s]*)\\s(.*)$#U This works perfectly. I now see that the preg_match() function returns an

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 19:07 +0900, Dave M G wrote: Robert, Thank you for your quick response and helpful advice. Use preg_match() and pay special attention to the manual as it refers to the third parameter :) The expression you need follows: #^([^\\s]*)\\s(.*)$#U This works

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Kevin Murphy
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

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Robert Cummings
On Wed, 2006-08-09 at 08:11 -0700, Kevin Murphy wrote: 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

Re: [PHP] Dividing, and keeping, text from the first space

2006-08-09 Thread Dave M G
Robert, Thank you for responding. The extra slashes are to properly escape the backslash character since you are using double quotes As I said you may want the following pattern in cases where no space exists: '#^([^\s]*)\s?(.*)$#' Thank you for your detailed explanation. Especially