In Objective C, what's the best way to extract multiple substrings of text around multiple patterns?

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-03-13T03:38:31Z Indexed on 2010/03/13 3:47 UTC
Read the original article Hit count: 505

For one NSString, I have N pattern strings. I'd like to extract substrings "around" the pattern matches.

So, if i have "the quick brown fox jumped over the lazy dog" and my patterns are "brown" and "lazy" i would like to get "quick brown fox" and "the lazy dog." However, the substrings don't necessarily need to be delimited by whitespace.

I have a hunch that there's a very easy solution to this, but I admit a disturbing lack of knowledge of Objective C string functions.

© Stack Overflow or respective owner

Related posts about nsstring

Related posts about objective-c