如何在我的代码中阻止一些标点符号 [英] How to block some punctuation in my code

查看:114
本文介绍了如何在我的代码中阻止一些标点符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

有人能指导我找出如何在我的代码中阻止一些标点符号吗?
我想输入一个浮点数,并且我不希望逗号与点."相符,但是¬
像这样的真实逗号,
我绝对不知道如何利用常规¬
为此表达.
我的代码如下所示:

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

推荐答案

本网站 http://www.regular-expressions.info / [ ^ ]具有各种正则表达式,包括用于浮点 www.regular-expressions.info/floatingpoint.html [
This site http://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[^]


这篇关于如何在我的代码中阻止一些标点符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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