How to trim only alphabets using javascript or jquery -
have scenario need trim alphabets string , display numbers , special characters.
var abc = "hai 40.00"; // output : 40.00 var xyz = "hai 40.00 - 50.00 was" // output : 40.00 - 50.00 any generic way handle this.
try this:
var xyz = "hai 40.00 - 50.00 was" xyz = xyz.replace(/[a-z]*/gi, '').trim(); alert(xyz); [a-z]: match alphabets*: matches preceding set 0 or more timesg: global flag, not stop after first matchi: case insensetive matchtrim: remove leading , trailing spaces
Comments
Post a Comment