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

  • SEARCH
  • Home
  • 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 6131685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:00:25+00:00 2026-05-23T17:00:25+00:00

That should be really simple but it doesn’t want to work. I want to

  • 0

That should be really simple but it doesn’t want to work. I want to fetch CoreData using a NSPredicate that uses a NSRegularExpression. I would like to search for myString or myString_10 (10 being any possible number, eg. myString_333).

This is my code:

NSString *regexString = [NSString stringWithFormat:@"%@_[0-9]+", value];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexString
                                                                           options:NSRegularExpressionSearch                                  
                                                                             error:&error];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(label = %@) OR (label = %@)", value, regex];

value is a string and label is the entity’s key.

If value is “New Project”, the NSFetchRequest returns an array with one object, although, I have two labels in my model (“New Project” and “New Project_1”) that should be fetched.

What am I doing wrong?

  • 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-05-23T17:00:26+00:00Added an answer on May 23, 2026 at 5:00 pm

    The regular expression needs to be an NSString or part of the predicate when used. See Regular Expressions in the Predicate Programming Guide. Try using MATCHES instead of = and regexString instead of regex. You can reference ICU Regular Expressions for patterns if you have any issues.

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

Sidebar

Related Questions

I am trying to do something that should be really simple. I want to
This seems really simple, but how do I call a javascript function that's defined
I'm having quite a bit of trouble with something that should be really simple.
Seems really a simple thing but can't figure it out. I've been using the
I have a really simple function that should: change the wording (from expand to
I really feel that I should learn Lisp and there are plenty of good
We have 18 databases that should have identical schemas, but don't. In certain scenarios,
This should be simple but I cannot figure it out. I have this very
My question is really simple, but apparently nobody's experienced a similar error. I'm writing
I have a simple script that should cause one of three divs to be

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.