0

i have a string as abcsd[2].asdwdw[3].asdsds. I need to find and replace digit 3 with other. i have tried some but they only replace the first or all digits in the string.

1 Answer 1

1

Try

var x = 'abcsd[2].asdwdw[3].asdsds';
var newvalue = 5;
var y = x.replace(/(.*?\..*\[)\d+/, '$1' + newvalue)
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.