1

I would like to know if there is a way to perform replacement with regular expressions in JS using tagged expressions, like scintilla engine does (used in Notepad++, for example). For instance, to replace numbers with a colon as decimal separator by a dot, you may use the following expressions in Notepad++:

regexp: /([0-9]+),([0-9]{2})/ replace: \1.\2

Could I do something like this in JS?

Regards José

3 Answers 3

4

Yes.

str = str.replace(/([0-9]+),([0-9]{2})/, '$1.$2');
Sign up to request clarification or add additional context in comments.

Comments

1

You sure can!

"My test string with a 56,35% chance of success".replace(/([0-9]+),([0-9]{2})/gi, "$1.$2");

Comments

1

Use replace. Good documentation here:

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace

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.