Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:33:42+00:00 2026-06-05T23:33:42+00:00

//string NSString *haystack = @.test {test:test} .test2{dasf:asdF}; //pattern NSString *needle = @[^{}]*{[^{}]*}; What I

  • 0
//string
NSString *haystack = @".test {test:test} .test2{dasf:asdF}";
//pattern
 NSString *needle = @"[^{}]*{[^{}]*}";

What I want from this is .test {test:test} and .test2{dasf:asdF} in an array (rest of the code handles this) but for some reason this regexp is not working correctly because no results are found.

If

NSString *needle = @"[^{}]*";

I get the following

(
".test ",
"",
"test:test",
"",
" .test2",
"",
"dasf:asdF",
"",
""
)

which is expected. After a lot of fiddling it seems to be a problem with { and } in the regex but I can’t think why.

Incidently, if anyone can explain why I get these empty elements in the array above that would be useful to know as well.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:33:45+00:00Added an answer on June 5, 2026 at 11:33 pm

    Would you try using:

     NSString *needle = @"[^{}]*\{[^{}]*\}";
    

    indeed, { and } have special meaning in regexs (but they are sort of “automatically” escaped when used within [])

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used this code to cut the string NSString *titleString = @22.225453615805794,113.554006577014889; NSArray *array
I have the following code to parse a date from string: NSString * str
I want to create an macro for trimming my string. I use this code
This string: [NSString stringWithFormat:@%C%C%C%C, 0x31, 0x34f, 0x32, 0x20dd] ought to display as 12 with
I would like to create an NSDate from a string: NSString *mostRecentMentionMessageTimestamp = [mostRecentMessage
For example, if I start with this string: NSString * labeltext = @abcdefghijk; I
I have a NSURL String: NSString *url = @http://ht21.easou.com/mty_ZhiQianQT.mp3?src=test&name=mty&size=100; What is the quickest way
I don't know why this method returns a blank string: - (NSString *)installedGitLocation {
In Objective C I've been using the following code to hash a string: -(NSString
I have a string NSString * myOldString = @This is a string (and this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.