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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:18:25+00:00 2026-05-27T09:18:25+00:00

I’m trying to do a bit of group matching using sed. Basically I have

  • 0

I’m trying to do a bit of group matching using sed.

Basically I have something like this:

func_name(4234,43543,76,1)

And I need to match the parameters of the function:

$ echo 'func_name(4234,43543,76,1)' | sed -n 's/\([0-9][0-9]*\).*/\1 /p' 
func_name(4234 

$ echo 'func_name(4234,43543,76,1)' | sed -n 's/\([[:digit:]]+\).*/\1 /p'
<empty>

$  echo 'func_name(4234,43543,76,1)'| sed -n 's/.*\([0-9][0-9]*\).*/\1 /p' 
1 
  • 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-27T09:18:25+00:00Added an answer on May 27, 2026 at 9:18 am

    If you know the number of parameters and they are always ‘simple’ (no nested parentheses and hence no embedded commas either), then:

    echo "func_name(4234,53543,76,1)" |
    sed 's/.*(\([^,)]*\),\([^,)]*\),\([^,)]*\),\([^,)]*\))/a1 \1; a2 = \2; a3 = \3; a4 = \4/'
    

    Note that this tolerates spaces after the commas (and before them too – but you wouldn’t leave spaces before, would you?).

    Or, if the parameters are simple unsigned integers and you know the function name, maybe:

    echo "func_name(4234,53543,76,1)" |
    sed 's/func_name(\([0-9]*\), *\([0-9]*\), *\([0-9]*\), *\([0-9]*\))/a1 \1; a2 = \2; a3 = \3; a4 = \4/'
    

    To get all the parameters in a single match, you have to do nested grouping:

    echo "func_name(4234,53543,76,1)" |
    sed 's/func_name(\(\([0-9]*\), *\([0-9]*\), *\([0-9]*\), *\([0-9]*\)\))/args = \1/'
    

    Now \2 .. \5 still refer to the separate arguments.

    echo "func_name(4234,53543,76,1)" |
    sed 's/func_name(\(\([0-9]*\)\(, *\([0-9]*\)\)\{3\}\))/args = \1/'
    

    This uses the repeat control \{3\} to find the arguments after the first.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to render a haml file in a javascript response like so:
I am trying to loop through a bunch of documents I have to put
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.