Tarek Salah uddin Mahmud Tarek Salah uddin Mahmud - 8 months ago 47
Javascript Question

Replace an expression in string using javascript

I have a string that has some numbers in the middle of the string.

For example,

var str = "abcd-123456.com"

I want to remove the numbers like this


I am not trying to replace all numbers.

I have to replace only
expression with

How do I do this in JavaScript?

var str = "abcd-123456.com"    
str = str.replace(/-[0-9]*/g, '')