0

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!

3
  • 2
    is this a homework question? Commented Feb 13, 2013 at 3:44
  • You can probably use Regex.Match with an expression like `"(.+)" to match everything between brackets (but it will include the brackets...). You will get a lot of inspiration from reading this earlier article Commented Feb 13, 2013 at 3:46
  • @floris there is no "Regex.Match" in obj-c. But the asker may want to check out the NSRegularExpression class Commented Feb 13, 2013 at 4:37

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.