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 1088967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:08:54+00:00 2026-05-16T23:08:54+00:00

I am not too familiar with regex and so I been having some getting

  • 0

I am not too familiar with regex and so I been having some getting this to work with Apple’s NSRegularExpression

I am trying to remove words in parentheses or brackets…

For example:

NSString *str = @”How do you (remove parentheses words) within a string using”

resulting string should be: @”How do you within a string using”

Thanks you!!!

  • 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-16T23:08:55+00:00Added an answer on May 16, 2026 at 11:08 pm

    Search for

    \([^()]*\)
    

    and replace with nothing.

    As a verbose regex:

    \(      # match an opening parenthesis
    [^()]*  # match any number of characters except parentheses
    \)      # match a closing parenthesis
    

    This will work fine if parentheses are correctly balanced and unnested. If parentheses can be nested (like this (for example)), then you need to re-run the replace until there are no further matches, since only the innermost parentheses will be matched in each run.*

    To remove brackets, do the same with \[[^[\]]*\], for braces \{[^{}]*\}.

    With conditional expressions you could do all three at once, but the regex looks ugly, doesn’t it?

    (?:(\()|(\[)|(\{))[^(){}[\]]*(?(1)\))(?(2)\])(?(3)\})
    

    However, I’m not sure if NSRegularExpression can handle conditionals. Probably not. Explanation of this monster:

    (?:           # start of non-capturing group (needed for alternation)
     (\()         # Either match an opening paren and capture in backref #1
     |            # or
     (\[)         # match an opening bracket into backref #2
     |            # or
     (\{)         # match an opening brace into backref #3
    )             # end of non-capturing group
    [^(){}[\]]*   # match any number of non-paren/bracket/brace characters
    (?(1)\))      # if capturing group #1 matched before, then match a closing parenthesis
    (?(2)\])      # if #2 matched, match a closing bracket
    (?(3)\})      # if #3 matched, match a closing brace.
    

    *You can’t match arbitrarily nested parentheses (since these constructs are no longer regular) with regular expressions, so that’s not a limitation of this regex in particular but of regexes in general.

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

Sidebar

Related Questions

This is some old code that I am not too familiar with : RequiredFieldValidator
I am not too familiar with regex and hope someone could help. example: This
I'm not too familiar with c++ and how instantiating objects work, so this is
I'm not too familiar with networking in JAVA but what i'm basically trying to
I'm not entirely too familiar with prototypes, and I'm sure this is the incorrect
I'm not very familiar to regex and even not able (maybe too tired?) to
I'm not too familiar with Java and need some help with an enumeration lookup
I am getting an error with Hibernate (I am not too familiar the API
This is complicated. I'm not too familiar with Access and I am a programmer
I'm not too familiar with regex but I know what I need to find-

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.