Removing Alphabetic Characters from a String

539 Views Asked by At

I need to remove the "ML" portion of "ML 11/07" but I want to keep the numbers as well as the slash.

Here is my current code (Google Apps Script)

var sec=second.replace("[^\\d.]", "");
tss.getRange(counter2, 5).setValue(sec); 
2

There are 2 best solutions below

0
guest271314 On

You can use RegExp /[a-z]/ig, .trim()

var sec = second.replace(/[a-z]/ig, "").trim();
0
Rafi Ud Daula Refat On

you can do this.

var string = "ML 11/07"
var result = string.split(" ");

console.log(result[1]);