Javascript replacing single quote with empty string -


this odd one! kind of want reason replace function isn't working correctly because of font. i've never seen issue before, , wonder if i'm overlooking something!?

i have following variable set static text '.

var lastname = "o'donnell"; 

in browser, console.log(lastname) outputs: o’donnell. instead of o'donnell. therefore, following replace method isn't working.

screenshot: enter image description here

return lastname.replace(/'/g, '') 

what doing wrong?

the character you're trying replace isn't same 1 in name.

best remove non alpha numeric characters instead, cater names such as:

  • o'neill
  • st. mary's

try:

lastname.replace(/\w/g, '') 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -