looking for data around matches
Posted: Wed Aug 03, 2005 11:15 am
I am wondering if this is possible with regex.
I want to be able look to the left or right of a certain pattern match, such as "hat" and return matches to the left of it so that for the following text:
"red hat
blue hat
green hat"
the array (red, blue, green) would be returned.
How would I go about this? Also how would I do this for the right side?
I want to be able look to the left or right of a certain pattern match, such as "hat" and return matches to the left of it so that for the following text:
"red hat
blue hat
green hat"
the array (red, blue, green) would be returned.
How would I go about this? Also how would I do this for the right side?