0

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.

4

4 回答 4

2

试试正则表达式,看看正则表达式

var x = 'john123,ricky43567,jecobs2'.replace(/[^a-z,]/ig, '')
于 2013-05-17T09:43:45.390 回答
2
var str = 'john123,ricky43567,jecobs2';
str = str.replace(/\d/g,'');

演示--> http://jsfiddle.net/zYfWc/2/

输出--> john,ricky,jecobs

于 2013-05-17T09:45:35.917 回答
0

试试这个

var str = 'john123,ricky43567,jecobs2';
  myString = str.replace(/(\d+)/g,'');
   alert(myString);
于 2013-05-17T09:47:24.210 回答
0

尝试正则表达式

[^a-z,]

所以它会是:

var str = 'john123,ricky43567,jecobs2';

var result = str.replace(/[^a-z,]/ig, '')

正则表达式演示

JSFiddle 演示

于 2013-05-17T09:50:41.093 回答