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 :: javascript group by property array of objects 
Javascript :: nodejs put array in file 
Javascript :: load json 
Javascript :: require statement not part of import statement javascript 
Javascript :: jquery check input 
Javascript :: useeffect will unmount 
Javascript :: how to clear pod cache in react native 
Javascript :: react-router-dom link target blank 
Javascript :: js get number from string 
Javascript :: window is not define nextjs 
Javascript :: Add table row in jQuery 
Javascript :: jquery on event snippet 
Javascript :: capitalize first letter javascript 
Javascript :: detect keypress 
Javascript :: nodejs get current directory 
Javascript :: js get user location 
Javascript :: enzyme change input value 
Javascript :: make the log do a jump in line js 
Javascript :: array to set javascript 
Javascript :: window.history.pushstate typescript 
Javascript :: javascript set delay 
Javascript :: bootstrap datetimepicker onchange event 
Javascript :: min object value in array 
Javascript :: react data attributes event 
Javascript :: axios file upload 
Javascript :: How to remove text from a string in javscript 
Javascript :: get columns of array list json js 
Javascript :: Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. 
Javascript :: npm youtube-react 
Javascript :: This version of CLI is only compatible with Angular versions 0.0.0 || ^10.0.0-beta || =10.0.0 <11.0.0, but Angular version 9.1.3 was found instead. 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =