Trying to match before the start, and right after the end of my string. This question seemed up my alley: How to use sed/grep to extract text between two words?
I managed to match the start (1st match). But for the end (2nd match), it matched the last match.
Sample string:
Bob said that John is nice, which makes Bob nice.
I want to get "John is", so I look for the string between "Bob said"
baz="Bob said that John is nice, which makes Bob nice."
echo `echo "$baz" | sed 's/Bob said that \(.*\) nice/\1/'`
#result: John is nice, which makes Bob.
It matched the last "nice" instead of the next nice. Is there any way to match the next "nice"?