Is there a way to extract only date part from this string if the other text is not fixed:
Input: "6/27/2014 - is Today"
Expected: "6/27/2014"
Is there a way to extract only date part from this string if the other text is not fixed:
Input: "6/27/2014 - is Today"
Expected: "6/27/2014"
Try the following snippet:
var input = "6/27/2014 - is Today";
var expected = input.match(/\d{1,2}\/\d{1,2}\/\d{4}/)[0];
console.log(expected);
If that's the format all the time then you can also try .split() method
var date = "6/27/2014 - is Today".split(" ");
console.log(date[0]);