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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:09:06+00:00 2026-06-02T18:09:06+00:00

The title is not clear, so I write some sample to explain. There is

  • 0

The title is not clear, so I write some sample to explain.

There is a string, which contains many nested {}s:

 /users/{<\w{2,4}\d{3}>id}

You can see I use {} as a placeholder for path variables, and it can have regex inside and which can also have {}.

How to write a regex with java to parse the path pattern, find the {} parts which don’t have outer {}. For this example, it should be {<\w{2,4}\d{3}>id}.

Thanks~

UPDATE

The given example is too simple, it can be:

/users/{<\w{2,4}\d{3}>id}/{action}/{<\w{2,4}\d{3}>targetId}

The result should be:

{<\w{2,4}\d{3}>id}
{action}
{<\w{2,4}\d{3}>targetId}

So \\{.*\\} doesn’t work.

  • 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-02T18:09:07+00:00Added an answer on June 2, 2026 at 6:09 pm

    Will you have such case as /users/{regex1}/{regex2} ?

    If yes, in this case "\\{.*\\}" will return "{regex1}/{regex2}". 🙁

    If not "\\{(.*)\\}" is good enough, being greedy you’ll go for the whole expression you asked for. 😉

    EDIT:

    With your edited question then the comment from @aix above was the right answer :
    Find the `{}` part which doesn't have outer `{}` by regex

    He pointed out your problem is similar with the one solved there: Regular Expression to match outer brackets

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

Sidebar

Related Questions

My question is not clear at title [i can not write it exactly] e.g
The title is not very clear, so I'll try to explain better. I have
If title is not clear: I want to read to and to write from
Sorry the title is not very clear. This is a follow up to my
As the title says, I'm not clear on when such a subroutine will be
I am not sure how clear my question is by the title, but I
I hope the title and following text are clear, I'm not very familiar with
The title might not explain my problem fully but I wasn't sure how to
Sorry if my title is not clear, I'm not sure how to word this.
Sorry if title is not too clear but I think it's about right. NEhow,

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.