How do I remove this numbers from text?
нани1,Ñпални1
视频3,教程3,
книги3,ÑÐºÐ°Ñ‡Ð°Ñ 5‚web2.0
above is forieng form of foreign languages which is stored in MySQL. I want to remove
numbers from above all lines. say 1 , 3 , 5
etc. and I want to keep web2.0
note:- there are about 300k lines. above is just a sample.
preg_replace('/(\w)\d+$/m', '$1', $tags);
the above one is an option f开发者_运维技巧or almost all cases but this fails in above case...
Since you tagged this question with php I assume you mean something like this:
<?php
$string = preg_replace ('/[0-9]+/', '', $string);
?>
$str = 'нани1,Ñпални1
视频3,教程3,
книги3,ÑÐºÐ°Ñ‡Ð°Ñ 5‚
';
$str = preg_replace('/\d+/', '', $str);
var_dump($str);
Output
string(122) "нани,Ñпални
视频,教程,
книги,ÑÐºÐ°Ñ‡Ð°Ñ ‚
"
CodePad.
Update
<?php
$str = 'нани1,Ñпални1
视频3,教程3,
книги3,ÑÐºÐ°Ñ‡Ð°Ñ 5‚web2.0
';
$str = preg_replace('/(?<!\w|\.)\d+/', '', $str);
var_dump($str);
Output
string(130) "нани,Ñпални
视频,教程,
книги,ÑÐºÐ°Ñ‡Ð°Ñ ‚web2.0
"
I am not sure exactly your exclusions, but this won't match any number proceeded by a word character (\w
) or by a period (\.
).
CodePad.
精彩评论