freshking
freshking

Reputation: 1864

Substrings in String

in my app I need to search for sub strings in a very long string. This string is read from a file with multiple lines.

I want to read the substring between "(" and ")" which are often available in the string and save them to an array. Example of string:

bla bla bla ( text) bla bla bla bla (text) bla bla
bla ( text) bla bla bla bla (text) bla bla ( text )

The "text" parts are the ones I need.

What would be the most efficient way of doing this?

Thanks a lot!

Upvotes: 0

Views: 148

Answers (1)

Ganapathy
Ganapathy

Reputation: 4614

Use NSScanner Scanner and Scan up to the "(" first , then scan it, then scan up to the ")". Then get the last scan result.

Upvotes: 1

Related Questions