本文介绍了如何在我的代码中阻止一些标点符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好, 有人能指导我找出如何在我的代码中阻止一些标点符号吗? 我想输入一个浮点数,并且我不希望逗号与点."相符,但是¬ 像这样的真实逗号,我绝对不知道如何利用常规¬ 为此表达. 我的代码如下所示:
Hi everybody, would somebody please guide me in finding out how to block some punctuation in my code? I''d like to enter a floating point number and I don''t want a comma with the point ".", but ¬ the comma with the real comma like this ", I have absolutely no idea of how to utilize regular ¬ expression for this. My code looks something like this:
float value = Convert.ToSingle(Console.Readline()); string rex = @"[0-9],"; // I don't know how to continue from here on有人可以帮我吗? Stefan
Can somebody please help me? Stefan
推荐答案本网站 www.regular-expressions.info / [ ^ ]具有各种正则表达式,包括用于浮点 www.regular-expressions.info/floatingpoint.html [ ^ ]. 只需用逗号替换示例中的点即可. This site www.regular-expressions.info/[^] has all kinds off regular expressions, including for floating points www.regular-expressions.info/floatingpoint.html[^]. Just replace the point in the sample with a comma.
尝试: [+-]?\d+\,\d+
我昨天刚刚读过这篇文章,它使正则表达式非常简单 轻松学习正则表达式(RegEx) [ ^ ] I just read this yesterday and it makes regular expressions really simple Learn Regular Expressions (RegEx) with Ease[^]
更多推荐
如何在我的代码中阻止一些标点符号
发布评论