There isn’t a built-in equivalent, but you can get close to one with replace
:
data = data.replace(/[\-_]/g, function (m) {
return {
'-': '+',
'_': "https://stackoverflow.com/"
}[m];
});
More Related Contents:
- How do I convert special UTF-8 chars to their iso-8859-1 equivalent using javascript?
- Submit form and stay on same page?
- How can I handle Javascript in a Perl web crawler?
- Are all JSON objects also valid JavaScript objects?
- Unicode value \uXXXX to Character in Javascript
- Detect browser character support in javascript?
- Jquery ignores encoding ISO-8859-1
- Convert non-ASCII characters (umlauts, accents…) to their closest ASCII equivalent (for slug creation)
- How can I use Perl to grab text from a web page that is dynamically generated with JavaScript?
- Is there a way to execute JavaScript in Perl?
- Day Name from Date in JS
- React JS – Uncaught TypeError: this.props.data.map is not a function
- How are JavaScript arrays represented in physical memory?
- How can I detect an address bar change with JavaScript?
- Javascript equivalent of php’s strtotime()?
- ES6: Is it dangerous to delete elements from Set/Map during Set/Map iteration?
- Removing page title and date when printing web page (with CSS?)
- JavaScript: getting ImageData without canvas
- What is the defined execution order of ES6 imports?
- forEach loop through two arrays at the same time in javascript
- Using elements that are added to an array with (document.getElementById(‘ID’))
- How do you pack one 32 bit integers into 4, 8bit ints in GLSL / WebGL?
- Sum values of objects in array
- How to pass data from one page to another page html
- How to split string while ignoring portion in parentheses?
- onDeviceReady not firing in PhoneGap hello world app
- How do I reload the page without the query parameters?
- How to access multiple Realtime Database instances in Cloud Functions for Firebase
- Why isnt window.location.href= not forwarding to page using Safari?
- What is the difference between window, window.top and window.parent?