如何在我的代码中阻止一些标点符号

编程入门 行业动态 更新时间:2024-10-15 02:31:31
本文介绍了如何在我的代码中阻止一些标点符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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[^]

更多推荐

如何在我的代码中阻止一些标点符号

本文发布于:2023-10-08 15:11:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472994.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标点符号   代码   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!