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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:28:23+00:00 2026-06-11T23:28:23+00:00

This might be a dumb question but are ( ) supported by sed? I

  • 0

This might be a dumb question but are ( ) supported by sed? I know \\( and \\) hold what is between them so you can access it by \1 or whatever number. I need a regex to look for parentheses and save what is between them.

sed 's/.*( .* \([[:alnum:]]+\) *).*/\1/' file

So I am looking for this:

possibly some stuff ( possibly some stuff [letters or numbers] possibly some stuff )

I need the outer ()s to be found, but you can’t \ them or else it thinks you want to save what is inside. Basically I only need to find the ()s so I can save some stuff inside them.

I am going to keep looking for how to do this but if any of you know how it would really help me out. I tried using "" and '' and unless I used incorrect syntax of some kind that doesn’t work. Thank you for any help you can provide.

Edit:Specific example: I want:

    aname = (type name){ value, value }. 

I want to know how to look for ()s and {} specifically in sed because they have other meanings. I assume \{ and \} is how you get {}s but I am not sure how to get ()s. Also I know the previous sed expression won’t find that, it was just a quick example I wrote down in order to show that I want to look for () in the regex. I am sorry if I have caused any confusion. Just so you guys can see this is my current regex:

    start line   aname        =          (        type           name    )         { values }; 

    sed 's/^\([[:alnum:]]\)+ *={1} *[^()]({1} *[[:alnum:]]+ +\([[:alnum:]]\)+ *) *\{{1}\(.*\)\};/init_\2\( \&\1, \3)/' file
  • 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-11T23:28:24+00:00Added an answer on June 11, 2026 at 11:28 pm

    sed (and other utilities which use Posix Basic Regular Expressions) don’t give any special meaning to ( and ) so you can just use them like any other character. \( and \) are the group delimiters.

    BRE’s really should die. Long, long ago, Posix defined “Extended” Regular Expressions (EREs) in which the grouping delimiters are ( and ) and you use \( and \) to match parentheses, which is a lot more intuitive. There is a similar difference between BRE and ERE treatment of { and } (numerical repetition operators). EREs also include the | and + operators.

    grep and sed both default to using BREs, but can be persuaded to use EREs with the correct command-line flag: grep -E and sed -r. gawk uses EREs with some GNU extensions and some deviations from the standard, including the fact that you must specify –re-interval if you want to use { and }. [rant]It sometimes amazes me that we tolerate all this insanity. There should be just one regex standard, and all utilities should use it without exceptions.[/rant]

    If your regex with ( and ) is not working as you expect, please provide specific examples of patterns which it fails on, and your expected outcome. My suspicion is that it has to do with the space characters in your pattern, if that is actually the pattern you’re using.

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

Sidebar

Related Questions

Ok so this might be a dumb question, but I can't seem to figure
This might be a dumb question, but maybe someone can provide some insight. I
This might be a dumb question but I can't get this super simple script
So this might be a dumb question but I don't know what to ask
This might be an extremely dumb question, but I simply can't understand the problem
I know this might sound like a dumb question, but I have looked every
This might be a dumb question, but I'd love to know if there was
This might seem like a dumb question, but can GameKit be used for apps
I know you might think this is a duplicate or a dumb question. But
This might be a dumb question. But does ADO.net support updating to a database

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.