Quantcast
Channel: Replace all occurrences of a string no matter how different it written - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by Sam for Replace all occurrences of a string no matter how different...

What you're looking for is a regex replace. You need to write a regular expression which will match the text that you want to change and then use it with String.replace.var newString =...

View Article



Answer by Ele for Replace all occurrences of a string no matter how different...

This regex /(TEST)\s*\((\s*)'([\d]?)'(\s*)\)/g captures five groups:Word TESTSpaces between TEST and the first (Spaces between ' and the inner number.The inner number.Spaces between ' and the last...

View Article

Answer by treyhakanson for Replace all occurrences of a string no matter how...

Use a regular expression: let str = "TEST ('1') TEST('2') Blah BLah TEST ( '1' ) TEST( '2' )"; const re = /TEST\s*\(\s*'([\d]*?)'\s*\)/g; str = str.replace(re, "TEST('$1.node')"); console.log(str) /*...

View Article

Replace all occurrences of a string no matter how different it written

I'm trying to see if this can be accomplished in plain and pure JavaScript.Lets say I have a string :var ourstring = "Blah TEST ('1') TEST('2') Blah BLah TEST ( '1' ) TEST( '2' )";Please pay attention...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>