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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -