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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:52:31+00:00 2026-06-16T11:52:31+00:00

From the below string, I need NUM = 12122 and CheckFrom = 02453226170 only

  • 0

From the below string, I need NUM = 12122 and CheckFrom = 02453226170 only

String s="shopNumber = \"shop 1\", NUM = \"12122\", Reference = \"NUM1\", CheckFrom = \"02453226170\""

how can I do this using regular expression and replaceall function of String class?

  • 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-16T11:52:32+00:00Added an answer on June 16, 2026 at 11:52 am

    Using Matcher.find would make this task a lot easier to extract out the name/value pairs. Essentially you are looking for the pattern word = "number":

    Matcher m = Pattern.compile("(\\w+) = \"(\\d+)\"").matcher(s);
    StringBuilder builder = new StringBuilder();
    while (m.find()) {
       builder.append(m.group(1));
       builder.append("=");
       builder.append(m.group(2));
       builder.append(" ");
    }
    

    m.group(1) relates to the first captured group, (i.e. the match from the word \w+)

    Builder contains:

    NUM=12122 CheckFrom=02453226170
    

    Update:
    From your question in the comments, you could use instead:

    Pattern.compile("(NUM = \"\\d+\").*( CheckFrom = \"\\d+\")")
    

    and append the 2 groups together to get your String.

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

Sidebar

Related Questions

How can I clean away 29% from the string below using Javascript? This is
i need Enumarable value from below class but give error public static Enumerable LoadDataByName(string
Given below is program for encrypting a string. I had taken this code from
How to get private key in string from below... key = paramiko.RSAKey.generate(1024) ssh_key =
I have below string String str=select * from m_menus; select * from m_roles; I
I have the code below: string SQL = select * from + TableName; using
Please have a look at the code below: import string from collections import defaultdict
Hi I'm passing path string to Groovy Script from Scala like below but when
I need a regex (JavaScript) which will extract shortforms from a string for example
I need some help to extract multiple substrings from a string. An example of

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.