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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:24:58+00:00 2026-06-13T22:24:58+00:00

I have the following text abc <THIS> abc <THAT> abc <WHAT> abc where abc

  • 0

I have the following text

abc <THIS> abc <THAT> abc <WHAT> abc

where abc is a placeholder for a well defined expression. I’d like to extract the 3 terms in the brackets and save them in 3 separate variables. Is is possible to do that without parsing the text 3 times? Basically I’d like to capture and somehow “export” multiple groups.

It’s clear that I can extract one of them like this:

VARIABLE=`echo $TEXT | sed "s_abc <\(.*\)> abc <.*> abc <.*> abc_\1_g"`

But is it possible to get all 3 of them without running sed 3 times?

Other (portable) solutions without sed are also welcome.

  • 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-13T22:25:00+00:00Added an answer on June 13, 2026 at 10:25 pm

    If there are any characters that you know will not appear in THIS, THAT, or WHAT, then you can write something like this:

    IFS=$'\t' read -r VAR1 VAR2 VAR3 \
        < <(sed 's/^abc <\(.*\)> abc <\(.*\)> abc <\(.*\)> abc$/\1\t\2\t\3/' \
                 <<< "$TEXT"
           )
    

    telling sed to use that separator in its output, and read to use that separator in its input.

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

Sidebar

Related Questions

I have the following regular expression: (</?[a-z][a-z0-9]*[^<>]*>) I have the following text: <DIV><P class='abc'>Hello
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
I have the following text contained within a field in my DB: [quote:5a7b87febe=mr smith]This
I have the following text, I need to extract the exception name and the
I have the following text: We%27re%20proud%20to%20introduce%20the%20Amazing I'd like to remove the encoding using PHP,
I have the following text, I need to extract the exception name and the
If I have a method chain like the following: var abc = new ABC();
i have a flash video called abc.swf that i would like to play when
Assume, that we have a file like this: l1 abcdefgh l2 abcde l3 some
I've got a regular expression that looks something like this: a(|bc) this expression matches

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.