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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:00:02+00:00 2026-05-26T19:00:02+00:00

I need to convert some variables that use parentheses instead of bracket in a

  • 0

I need to convert some variables that use parentheses instead of bracket in a Javascript file. For example, MyVariable(i) should be MyVariable[i].

I use the Find and Replace tool of Visual Studio with this Regex :

MyVariable\({(.+)}\)

and replace with:

MyVariable\[\1\]

This work fine for case like :

asdas.MyVariable(i+1)
asdas.MyVariable(i)
asdas.MyVariable(i).asd
MyVariable(i+1)

But doesn’t work for case like

if (parseInt(OtherObject.MyVariable(i+1).Dest.XYZ)==SINK_STATE_TYPE || OtherObject.MyVariable(i).X == "ok")

The last one will do take the first parentheses and the last one of the line and act weird. What do I need to change in the Regex to be able to make it works with line that has multiple parentheses.

  • 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-05-26T19:00:03+00:00Added an answer on May 26, 2026 at 7:00 pm

    Your pattern is greedy. The (.+) part matches everything, including a closing parenthesis ) character until it reaches the last ) character. To make it non-greedy you can use # instead of +, which means “match one or more occurrences of the preceding expression, and match as few characters as possible.” In .NET this is usually handled by placing a ? after it, such as .+? but the Visual Studio regex flavor is different and uses the # metacharacter instead.

    The updated pattern becomes:

    MyVariable\({(.#)}\)
    

    You can also use [^)]+, which matches any character that is not a ) character. When it encounters a ) it will stop matching. This alternate pattern is:

    MyVariable\({([^)]+)}\)
    

    If you’re familiar with the .NET regex flavor you might be interested in checking out the Visual Studio 2010 Productivity Power Tools, which has extended Find/Replace to allow the .NET regex flavor to be used.

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

Sidebar

Related Questions

I need to convert some files to PDF and then attach them to an
I need to convert some strings, and pull out the two first integers e.g:
I need to convert some code done by someone else, to work in my
In a Win32/WTL/C++ app, I need to convert some 8.3 paths to their true
I have a need to convert Pixels to Points in C#. I've seen some
For some reason I need to cast/convert a DateTime into one of many custom
I have some classes and for some reason I need a procedure that create
I have a number of byte[] array variables I need to convert to string
I created some methods that use nested type parameters generic types in the parameter
I use some third-party template tags in my Django Application (maintained elsewhere) that return

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.