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 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

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The statement x++; is exactly equivalent to x = x… May 16, 2026 at 4:19 pm
  • Editorial Team
    Editorial Team added an answer No, inverse doesn't help. you need to specify what you… May 16, 2026 at 4:19 pm
  • Editorial Team
    Editorial Team added an answer Some time ago I've found the following Code on the… May 16, 2026 at 4:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Let us suppose we are going to start new project - application that contains
Suppose I have a user table that creates strong relationships (Enforce Foreign Key Constraint)
Let's suppose I have such helper methods used by some object. private int MatchRegex(string
Looking for a best-practice advice: Let's suppose I have a Account object with limit
Hey folks, I have a question which feels stupid but I can't quite say
Suppose you have a webapp that gives users their own site on a subdomain
Suppose I want to allow to select our entity (from a dropdown, etc) on
Suppose we have an arbitrary string, s . s has the property of being
Consider the following situation: - Suppose my app allows users to create the states
suppose I have the following source table (called S): name gender code Bob 0

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.