user3532863 user3532863 - 6 months ago 3x
Javascript Question

How to replace date pattern in javascript string

How to remove a date patterns in a JavaScript string like below?
from "Mobile Phone 1/15/06" to "Mobile Phone"

var str ="Mobile Phone 1/15/06";

ccf ccf

You could use regex to match and replace the date pattern:

var str ="Mobile Phone 1/15/06";
var result = str.replace(/\s+\d{1,2}\/\d{2}\/\d{2}/g, '');