0

I am trying to do a querystring replace in javascript:

s = "http://localhost:8000/i/dashboard-view?&level_to_load=2#;"
s.replace('level_to_load=\d','HELLO')
"http://localhost:8000/i/dashboard-view?&level_to_load=2#;"

The result I want is:

"http://localhost:8000/i/dashboard-view?&HELLO#;"

What would be the correct regex to use, over level_to_load=\d ?

1 Answer 1

3

You need to pass a regex, not a string:

s.replace(/level_to_load=\d/,'HELLO')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.