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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:41:19+00:00 2026-06-15T17:41:19+00:00

I have a very straightforward problem. I am using this regular expression to match

  • 0

I have a very straightforward problem.

I am using this regular expression to match instances of {somestring}.

\{{1}(\w+?)\}{1}

The problem is that I need it to ignore instances of {{somestring}}, but of course, it is matching the inner {somestring} in {{somestring}}.

Any idea how I can tweak the expression to skip anything like {{somestring}}?

I am using vbscript’s regular expression engine.

  • 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-15T17:41:20+00:00Added an answer on June 15, 2026 at 5:41 pm

    If your regex engine supports lookarounds, they are the way to go:

    (?<!\{)\{\w+\}(?!\})
    

    This does literally what you want. The lookbehind asserts that there is no { preceding your {, and the lookahead asserts that there is no } following your }.

    Note that {1} does never do anything. Ever.

    Also note that you don’t need to make \w+ ungreedy, because it cannot consume } anyway.

    Finally, I just want to put it here, that an alternative to escaping { and } is to put it into a one-character character class. It’s a matter of taste which one you prefer but I like the readability of this one better:

    (?<![{])[{]\w+[}](?![}])
    

    EDIT:

    It seems like VBScript does not support lookbehinds.

    That is a bit of an issue. The closest thing you can get is:

    (^|[^{])[{]\w+[}](?![}])
    

    However, if the match is not found at the beginning of the string, this will include the preceding character in the match. This alone is not a problem, because you could get rid of that character through capturing of substring functions or something. However, matches cannot overlap, so if you have an input like {some}{string} you won’t easily get both matches (because the first } has to be part of the second match). Some engines provide \G as the equivalent of ^ for continuing matches, but VBScript does not seem to support that either. Hence, it’s going to get ugly from here on.

    What you could do is to exclude the closing } from the match (using another lookahead):

    (^|[^{])[{]\w+(?=[}](?![}]))
    

    Now you will get matches {some and }{string, so will have to append every match with } and remove the first character from every match that is not at the beginning of your string. Or if you can get hold of the captured results, you can use

    (^|[^{])([{]\w+)(?=[}](?![}]))
    

    Then retrieve capturing group 2 and append }.

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

Sidebar

Related Questions

Hi I have a query which is very straightforward to write in mysql but
I'm encountering a very strange problem using g++ 4.1.2. I have a very basic
I'll try and keep my sample code very straightforward, but it may have errors
I have this very straight forward question regarding Thread and Timer classes in Java
i have very serious problem if any tech expert can help...thank you in advance..
I have very very big html page/data. I need to fetch data under h1
I have very strange problem while I am submitting a practice problem on codechef.
I have a bit of a challenging problem. I'm using the Blogger JSON API
very new to signalR, and have rolled up a very simple app that will
A seemingly straightforward problem: I have a java.util.concurrent.Semaphore , and I want to acquire

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.