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

  • Home
  • SEARCH
  • 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 729899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:51:01+00:00 2026-05-14T06:51:01+00:00

Suppose I let the user to write a condition using Javascript, the user can

  • 0

Suppose I let the user to write a condition using Javascript, the user can write conditions to perform a test and return true or false. E.g.:

INS>5 || ASTO.valueBetween(10,210)

I want to find which variables are used in the script that the user wrote. I tried to find a way to get the identifier names in Java. The Rhino library didn’t help a lot. However I found that via handling exceptions I could get all the identifiers. So this problem is solved.

So everything is great, but there is one little problem. How can I replace these identifiers with a numeric identifier? E.g. INS should be _234 and ASTO should be _331.

INS and ASTO etc are entities in my database. I want to replace them, because the name may change. I could do it using a replace but this isn’t easy because:

  1. It should be reversible. E.g. ASTO to _234 and _234 to ASTO again.
  2. Replacing _23 with MPLAH may also replace _234. This could be fixed with regexp somehow.
  3. What if _23 is in a comment section? Rare to happen, but possible /* _23 fdsafd ktl */. It should also be replaced.
  4. What if it is a name of a function? E.g. _32() {}. Also rare, but it shouldn’t be replaced.
  5. What if it is enclosed in "" or ''?

I am sure that there are a lot more cases. Any ideas?

  • 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-14T06:51:02+00:00Added an answer on May 14, 2026 at 6:51 am

    Parhs – what you really need is a JavaScript parser. Basically, you will be re-implementing pieces of Rhino although it’s theoretically possible that Rhino already has hooks to do what you need (I’m not familiar with it so not sure); or you can extend Rhino since its source is 100% avialable from Mozilla. Another possible direction to look at is Google’s GWT.

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

Sidebar

Related Questions

Let's suppose I've to test this Java ClassA that depends on the difficult to
Let's suppose a user, Bob, gets SELECT privilege from John and Bob also gets
I am working in an application that creates online accounts(Let suppose Gmail) When user
Let's suppose that I'm displaying a web page whose URL is www.mysite.com?id=10&name=test (the URL
I am suppose to let the user enter a DateTime format, but I need
So I'm using SignalR, it's setup and working correctly on my Website. Let's suppose
Let's suppose I have all of these already provided: The name of a table
Let us suppose I have a table created as follows: create table `test_table` (
Let's suppose I have a css class named foo. I would like to have
Let's suppose we have an open source project running in a server. Is there

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.