In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Ed Lazor) wrote:

> I've been banging my head against regular expressions all night... help 
> would be greatly appreciated.  Could you give me examples on how to do the 
> following?
> 
> Pull everything except a specific word from a sentence.
<snip more examples>

First you need to decide what you mean by "word".  If it's simply "the 
stuff separated by a space", then you might find it simpler to explode your 
sentences on the space character, then loop through the resulting array 
using string functions to do your comparisons .  Regex is great for the 
power and flexibility it offers, but if you're really struggling with the 
syntax, using constructs that are more familiar may help you move forward.

On the other hand, it's frequently the case that one needs a more 
sophisticated definition of "word".  Is it just adjacent letters?  What if 
they're interrupted by a hyphen?  Are leading/trailing punctuation marks 
included?  Do adjacent digits count as words?   Etc. Once you've defined 
the pattern comprising a "word", you can then translate it into regex--or 
get more help from others in making the translation.

-- 
CC

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

Reply via email to