javascript - Regex to filter out certain characters -


what regex string if provided random string such :

"u23ntfb23nnfj3mimowmndnwm8"

and wanted filter out characters such 2, b, j, d, g, k , 8?

so in case, function return '2bjd8'.

there's lot of literature on internet nothing straight point. shouldn't hard create regex filter string right?

ps. not homework cool daft punk

you need create regular expression , execute on string.

this need :

    var str = "u23ntfb23nnfj3mimowmndnwm8";      var re = /[2bjd8]+/g;      alert(str.match(re).join(''));

to matches use string.prototype.match() regex.

it give following matches in output:

2 b2 j d 8


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -