从字符串中删除垃圾字符(不包括html标签和印地文字符) [英] remove junk character from the string (excluding html tags and hindi character)
本文介绍了从字符串中删除垃圾字符(不包括html标签和印地文字符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有一些垃圾字符和一些印地文字符的可变字符串,我想删除所有不包括印地文字符的垃圾字符。
例如
string sjunk = < div> te♠st data here♠♣!@#$%^& *♠♣< p> dfdsससेपहलेकब-कबशाहरुखखान< / p> ;;
sjunk = System.Text.RegularExpressions.Regex.Replace(sjunk, @ [^ \ u0000-00 \ u007F], );
<来自上述正则表达式的
所有的印地语和垃圾角色都被替换了,我只想删除垃圾角色。
谢谢..
解决方案
%^& *♠♣< p> dfdsससेपहलेकब-कबबशाहरुखखान< ; / p为H. ;
sjunk = System.Text.RegularExpressions.Regex.Replace(sjunk, @ [^ \\\ -\ u007F], );
来自上面的正则表达式所有的印地语和垃圾角色都被替换了,我只想删除垃圾角色。
谢谢..
您需要更新正则表达式以允许来自梵文字符块 [ ^ ]:
sjunk = System.Text.RegularExpressions.Regex.Replace(sjunk,< span class =code-string> @ [^ \\\ -\\\ 0000F \ u0900-\ u097f], 跨度>);
I have a mutable string with some junk character and some hindi character, I want to remove all the junk character excluding hindi character.
for example
string sjunk="<div>te♠st data here ♠ ♣ !@#$%^&* ♠ ♣<p>dfdsससे पहले कब-कब शाहरुख खान </p> ";
sjunk = System.Text.RegularExpressions.Regex.Replace(sjunk, @"[^\u0000-\u007F]", "");
from the above regex all the Hindi and junk character got replaced, I want only junk character to be removed.
Thanks..
解决方案
%^&* ♠ ♣<p>dfdsससे पहले कब-कब शाहरुख खान </p> "; sjunk = System.Text.RegularExpressions.Regex.Replace(sjunk, @"[^\u0000-\u007F]", "");
from the above regex all the Hindi and junk character got replaced, I want only junk character to be removed.
Thanks..
You'll need to update your regular expression to allow characters from the Devanagari character block[^]:
sjunk = System.Text.RegularExpressions.Regex.Replace(sjunk, @"[^\u0000-\u007F\u0900-\u097f]", "");
这篇关于从字符串中删除垃圾字符(不包括html标签和印地文字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文