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 :: ReferenceError: http Server is not defined 
Javascript :: are you sure you want to proceed click ok button javascript code 
Javascript :: copy to clipboard javascript 
Javascript :: how to add parameters to url javascript 
Javascript :: Node Sass could not find a binding for your current environment 
Javascript :: javascript for loop starting from end 
Javascript :: find all images without alternate text 
Javascript :: javascript remove text from string 
Javascript :: imagebackground in react native 
Javascript :: refresh event in javascript 
Javascript :: jquery modify style attribute 
Javascript :: mongodb filter array 
Javascript :: ng new module w route 
Javascript :: s3 list objects in folder node js 
Javascript :: subtract two date javascript 
Javascript :: js promis with ajax 
Javascript :: how to return 5 records instead of 10 records in datatable 
Javascript :: discord.js send message to specific channel 
Javascript :: jquery get multiple input values by name 
Javascript :: ffmpeg convert mp4 to avi 
Javascript :: chartjs how to disable hover lable 
Javascript :: disable strict mode angular 
Javascript :: js close window 
Javascript :: js check if element hidden 
Javascript :: angular contains both .browserslistrc and browserslist 
Javascript :: js find first line break in string 
Javascript :: javascript delete first character from string 
Javascript :: javascript function convert bytes into mb 
Javascript :: javascript parsefloat() method 
Javascript :: make select option selected javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =