user160820
user160820

Reputation: 15220

Matching only non-numeric elements

I am trying to search only non-numeric elements from a string like

info,25892,25696,26421,26513,13486,26976,27588,26000,22840,bla,aby3

using Regular expression. I have tried and this way I can find only words

 `[^\d,]+ `

but alphanumerics I can't

Upvotes: 0

Views: 95

Answers (1)

Bartosz Grzybowski
Bartosz Grzybowski

Reputation: 1179

If You are using PHP You can easly achive this w/o using regular expressions at all, just run:

$string = '1234,45,67f,a67a,434334,3fd';
$foo = explode(',', $string);
$foo = array_filter($foo, 'is_numeric');
var_dump($foo);

Upvotes: 1

Related Questions