View Single Post
Old 01-31-2013, 08:23 PM   PM User | #8
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,461
Thanks: 52
Thanked 457 Times in 455 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
Here's the thing: Lets say the string is this:
"The dog jumped over the moon. He was happy to see me. I left in a hurry"

and the word is "happy"

in that case, all I want is
"He was happy to see me."

If it's
"was happy to see me. I left in a hurry"

all I want is
"was happy to see me."

If it's
"The dog jumped over the moon. He was happy to see"

all I want is:
"He was happy to see"

splitting it on the punctuation is probably the safest way, but then I have to loop through the array to find out which split is the one that I want. Which is why regex seems to be the answer...
xelawho is offline   Reply With Quote