如何从一个字符串中去除标点符号? [英] How can I strip punctuation from a string?

查看:1141
本文介绍了如何从一个字符串中去除标点符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关,希望到都具有的回答 - 在30秒这个问题的一部分,我专门找C#

但在一般情况下,是什么剥夺任何语言标点符号的最佳方式?

我要补充:理想情况下,解决方案将不会要求您列举所有可能的标点符号。

相关报道:<一href=\"http://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string-in-python\">Strip标点符号在Python


解决方案

 新的字符串(myCharCollection.Where(C =&GT;!char.IsPunctuation(C))ToArray的()) ;

For the hope-to-have-an-answer-in-30-seconds part of this question, I'm specifically looking for C#

But in the general case, what's the best way to strip punctuation in any language?

I should add: Ideally, the solutions won't require you to enumerate all the possible punctuation marks.

Related: Strip Punctuation in Python

解决方案

new string(myCharCollection.Where(c => !char.IsPunctuation(c)).ToArray());

这篇关于如何从一个字符串中去除标点符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆