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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:14:41+00:00 2026-05-12T14:14:41+00:00

Consider the following strings: 1) Scheme ID: abc-456-hu5t10 ( High priority ) ***** 2)

  • 0

Consider the following strings:

1) Scheme ID: abc-456-hu5t10 (High priority) *****

2) Scheme ID: frt-78f-hj542w (Balanced)

3) Scheme ID: 23f-f974-nm54w (super formula run) *****

and so on in the above format – the parts in bold are changes across the strings.

==> Imagine I’ve many strings of format Shown above.
I want to pick 3 substrings (As shown in BOLD below) from the each of the above strings.

  • 1st substring containing the alphanumeric value (in eg above it’s “abc-456-hu5t10”)
  • 2nd substring containing the word (in eg above it’s “High priority”)
  • 3rd substring containing * (IF * is present at the end of the string ELSE leave it )

How do I pick these 3 substrings from each string shown above? I know it can be done using regular expressions in Perl… Can you help with this?

  • 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-12T14:14:41+00:00Added an answer on May 12, 2026 at 2:14 pm

    You could do something like this:

    my $data = <<END;
    1) Scheme ID: abc-456-hu5t10 (High priority) *
    2) Scheme ID: frt-78f-hj542w (Balanced)
    3) Scheme ID: 23f-f974-nm54w (super formula run) *
    END
    
    foreach (split(/\n/,$data)) {
      $_ =~ /Scheme ID: ([a-z0-9-]+)\s+\(([^)]+)\)\s*(\*)?/ || next;
      my ($id,$word,$star) = ($1,$2,$3);
      print "$id $word $star\n";
    }
    

    The key thing is the Regular expression:

    Scheme ID: ([a-z0-9-]+)\s+\(([^)]+)\)\s*(\*)?
    

    Which breaks up as follows.

    The fixed String “Scheme ID: “:

    Scheme ID: 
    

    Followed by one or more of the characters a-z, 0-9 or -. We use the brackets to capture it as $1:

    ([a-z0-9-]+)
    

    Followed by one or more whitespace characters:

    \s+
    

    Followed by an opening bracket (which we escape) followed by any number of characters which aren’t a close bracket, and then a closing bracket (escaped). We use unescaped brackets to capture the words as $2:

    \(([^)]+)\)
    

    Followed by some spaces any maybe a *, captured as $3:

    \s*(\*)?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following function which fills an array with strings(questions): global $questions; function printQuestions($lines){
Consider the following regular expression pattern = (0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/(19|20)\d\d This pattertn represents date strings in
Consider the following string: ABC . I would like to capture the following groups
Consider the following strings breaking out a of a simple prison this is b
I want to hide strings inside a div. Consider the following example where I
Consider following string Some string with quotes and \pre-slashed\ quotes Using regex, I want
Consider the following HTML string: <p>This is line 1 <br /> and this is
Consider following program: static void Main (string[] args) { int i; uint ui; i
Consider the following code: std::string my_error_string = Some error message; // ... throw std::runtime_error(std::string(Error:
Consider the following line: readonly private string TARGET_BTN_IMG_URL = @\\ad1-sunglim\Test\; In this line, why

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.