Reputation: 328
This question is related to login. This answer may be simple but still 30 mins I am trying using jquery OR javascript.
Given string Example :
john123,ricky43567,jecobs2
and many more like this
Retrieve only character from it.
above string result will be like..
john,ricky,jecobs
Thanks in advance.
Upvotes: 0
Views: 94
Reputation: 17183
Try a regex
[^a-z,]
So it would be:
var str = 'john123,ricky43567,jecobs2';
var result = str.replace(/[^a-z,]/ig, '')
Upvotes: 0
Reputation: 505
try this one
var str = 'john123,ricky43567,jecobs2';
myString = str.replace(/(\d+)/g,'');
alert(myString);
Upvotes: 0
Reputation: 44740
var str = 'john123,ricky43567,jecobs2';
str = str.replace(/\d/g,'');
Demo -->
http://jsfiddle.net/zYfWc/2/
Output -->
john,ricky,jecobs
Upvotes: 2
Reputation: 388316
Try a regex like, have look at regular expression
var x = 'john123,ricky43567,jecobs2'.replace(/[^a-z,]/ig, '')
Upvotes: 2