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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:35:23+00:00 2026-05-11T01:35:23+00:00

Unfortunately, despite having tried to learn regex at least one time a year for

  • 0

Unfortunately, despite having tried to learn regex at least one time a year for as many years as I can remember, I always forget as I use them so infrequently. This year my new year’s resolution is to not try and learn regex again – So this year to save me from tears I’ll give it to Stack Overflow. (Last Christmas remix).

I want to pass in a string in this format {getThis}, and be returned the string getThis. Could anyone be of assistance in helping to stick to my new year’s resolution?


Related questions on Stack Overflow:

  • How can one turn regular quotes (i.e. ', ") into LaTeX/TeX quotes (i.e. `', “'')
  • Regex: To pull out a sub-string between two tags in a string
  • Regex to replace all \n in a String, but no those inside [code] [/code] tag
  • 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. 2026-05-11T01:35:23+00:00Added an answer on May 11, 2026 at 1:35 am

    If your string will always be of that format, a regex is overkill:

    >>> var g='{getThis}'; >>> g.substring(1,g.length-1) 'getThis' 

    substring(1 means to start one character in (just past the first {) and ,g.length-1) means to take characters until (but not including) the character at the string length minus one. This works because the position is zero-based, i.e. g.length-1 is the last position.

    For readers other than the original poster: If it has to be a regex, use /{([^}]*)}/ if you want to allow empty strings, or /{([^}]+)}/ if you want to only match when there is at least one character between the curly braces. Breakdown:

    • /: start the regex pattern
      • {: a literal curly brace
        • (: start capturing
          • [: start defining a class of characters to capture
            • ^}: ‘anything other than }‘
          • ]: OK, that’s our whole class definition
          • *: any number of characters matching that class we just defined
        • ): done capturing
      • }: a literal curly brace must immediately follow what we captured
    • /: end the regex pattern
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Unfortunately I haven't coded Java for about five years and I absolutely can not
I just heard one of the clients having really bad performance on IE6 despite
Unfortunately I cannot post all of the source code here. I can describe the
Unfortunately, I have to deal with J2ME (which I consider ancient technology these days)
Unfortunately, I often find I need to reboot to wipe some unhealthy Xcode state.
Unfortunately, I have to use a C library with internal state in my Android
Unfortunately I have a pretty bad understanding of how to properly set up threading.
Unfortunately the cygwin GCC 4.5.3 pthread library implementation doesn't support the POSIX standard function
Unfortunately their Wiki is down for maintenance and the web is not being helpful.
Unfortunately I am not writing this question from my Developing PC so I might

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.