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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:40:46+00:00 2026-06-14T02:40:46+00:00

I am a noob to regex. I have string like:- String str = sbs

  • 0

I am a noob to regex.

I have string like:-

String str = "sbs 01.00 sip ${dreamworks.values} print ${fwVer} to 
              used ${lang} en given ${model}  in ${region}";

and
i have to extract all patterns matched with this type ${….}

Like:- for given str result should be

${dreamworks.values} 
${fwVer}   
${lang}
${model}
${region}

further if it finds any duplicates then gives only one .
for ex:-

String feed = "sip ${dreamworks.values} print ${fwVer} to ${fwVer} used
                ${lang} en ${lang}given ${model}  in ${region}"

result should be:-

 ${dreamworks.values}  
 ${fwVer}   
 ${lang}
 ${model}
 ${region}  

only

this is my answer:-

PLACEHOLDER_PATTERN = "\\$\\{\\w+\\}";

but this one not giving the correct result.
it gives only

${fwVer}
${lang}
${model}
${region}

So please suggest me correct regex.

  • 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-14T02:40:48+00:00Added an answer on June 14, 2026 at 2:40 am

    You are not considering the . in between the word. \\w does not include the dot(.).

    You need to change your pattern to: –

    PLACEHOLDER_PATTERN = "\\$\\{.+?\\}";
    

    dot(.) matches everything, and that is what you want right?

    Also, I have used here reluctant quantifier – .+? so that it only matches the first } after {, since if you use a greedy quantifier (.+), dot(.) will also match the } in the way till it finds the last }.


    UPDATE: –

    To get just the unique values, you can use this pattern: –

    "(\\$\\{[^}]+\\})(?!.*?\\1)"
    

    It will match only those pattern, which is not followed by the string containing the same pattern.

    NOTE: – Here, I have used [^}], in place of .+?. It will match any character except }. So, now in this case, you don’t need a reluctant quantifier.

    \1 is used for backreferencing, but we need to escape it with a backslash, and hence \\1, and (?!...) is used for negative look ahead.

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

Sidebar

Related Questions

I have a string something like [aaa][vad][adf], i would like to use regex to
I'm a complete noob to regex and I need help with splitting a string.
I need a RegEx guru to help me (I'm a noob). I have the
Another noob regex problem/question. I'm probably doing something silly so I thought I'd exploit
Yep - another noob regex query, which I can't seem to get. I'm trying
I'm copletly noob of regex, but i'm forced to use it. I've tried to
Noob question, apologies. I'm compiling Java in Windows Vista's command-line and have so many
Noob here again. I've followed the example given by Google Dev (and read a
Probably really simple for you Regex masters :) I'm a noob at regex, just
First time here, and I'm a bit of a mod_rewrite and regex noob, so

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.