so I have a list like this: And I want to look like this: My problem is, I try every way i know to replace the single quote but, nothing work, so far so god, I got this code: But I still getting the same result, any idea of how can i do it? Thank you very much to all!
Tag: replace
Format phone number in Javascript
I need to format phone number for example by replace(): From: +48 XX XXX XX XX where X is a number. Example: +48 12 345 67 89 To: +48 XXX XXX XXX Example: +48 123 456 789 Edit: My work: First, I tried to remove the spaces in string: phone.replace(‘ ‘, ”);: Before: +48 12 312 31 23 After: +4812
Using JavaScript do replace all occurrences of a few strings in HTML by the user input from a prompt
Context: I’m a newbie in JavaScript and I’m learning as I go with a little program I built for my job on customer service. It’s a HTML file with some some quick generic messages which are used by many attendants, each representing a branch from our company. I want each attendant to be able to customize their name and their
How to replace matching words within a page replacing the body.innerHTML only once?
The following function in JavaScript adds to each matching word a <mark> tag in the document’s body. This way, it highlights a word within the <body> if it’s an element within the array words. The issue I have is that the document.body.innerHTML is replaced at every iteration. Do you know how I can replace the matching words in the page
regex replace for multiple string array javascript
I have a array of string and the patterns like #number-number anywhere inside a string. Requirements: If the # and single digit number before by hyphen then replace # and add 0. For example, #162-7878 => 162-7878, #12-4598866 => 12-4598866 If the # and two or more digit number before by hyphen then replace remove #. For example, #1-7878 =>
How do replace some of the text in an attribute in all classes? (pure js)
I have a working example in jquery, but there are compatibility issues, so I want to rewrite this in pure javascript. How do I do this correctly? My attempt was like that, but it’s not a workable option: Answer
What is the appropriate use for the .replace method within this context/ within a .map method?
I’m trying to loop through an array of strings and for each element(string) in that array, change the character after the “_” underscore character to a “*” character. Strings are immutable so, pushing this all to a new array. The chain performs as expected when directly targeting the underscore for replacement: But the moment the actual intended function is pursued,
replaceAll in JavaScript for loop is too slow, looking for an alternative approach
I’m making a browser extension that replaces all profane words on a website with ***. Right now, I have a huge JS array with all the profane words (2k+ words). I’m using a for loop to loop over each word in the profaneWords array and replace any instance of a matching word with ***: With this, it takes about 5
Property ‘replace’ does not exist on type ‘IData’. What is missing?
I am tryign to create a cast function where a string with numbers is received as input, but when using the regex function “replace()” it doesn’t recognize it. Anyone know how can I declare “replace()” inside type IData? Answer Based on the comments so far, I think that there is a need to shortly explain types in JS (which translates
Passing $& in replace()-function to another function
This code will take str and put each word in a <span>. I want to add some functionality, so some words will be highlighted, but can’t figure out how to pass $& (which is a word) to the highLight function. Right now I have written {$&} which does not work. Answer You’re really close, but you have to pass a