Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

replacing characters in string javascript

var myStr = 'this,is,a,test';
var newStr = myStr.replace(/,/g, '-');

console.log( newStr );  // "this-is-a-test"
Comment

js replace characters in a string

var str = "Original string!";
var str = str.replace("Original", "New");
Comment

replace character inside a string in JavaScript

 function strReplace(){
        var myStr = 'quick_brown_fox';
        var newStr = myStr.replace(/_/g, "-");
        
        // Insert modified string in paragraph
        document.getElementById("myText").innerHTML = newStr;
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: define an async function 
Javascript :: mod operation in shopify 
Javascript :: javascript read consol input 
Javascript :: joi allow additional properties 
Javascript :: MaterialStateProperty width 
Javascript :: lodash find duplicate element index 
Javascript :: fibonacci recursion 
Javascript :: empty check on django json field 
Javascript :: javascript check for duplicates in array 
Javascript :: resize image in node.js 
Javascript :: learn mongodb 
Javascript :: getting the value of pi in javascript 
Javascript :: jquery values to array 
Javascript :: abrir dialog angular material 
Javascript :: appendchild javascript 
Javascript :: Math.avg 
Javascript :: body-parser is depreciated 
Javascript :: add and get tokens to securestore expo 
Javascript :: how to use if else inside jsx in react 
Javascript :: javascript add dom disabled 
Javascript :: get selected text 
Javascript :: load more button javascript 
Javascript :: get the length of an object vuejs 
Javascript :: bfs javascript 
Javascript :: sequelize select fields 
Javascript :: simple id using javascrip math randomt 
Javascript :: change build directory react 
Javascript :: es6 in nodejs 
Javascript :: added font to react native 
Javascript :: mongoose check if user exists 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =