点数后的两位数的浮点数的正则表达式(XX.XX)

Par*_*Par -2 regex

我不知道正则表达式是否足够好,我真的很难知道如何测试输入是否是点后两位数的浮点数.

在此先感谢您的帮助!

Joh*_*son 5

If x is number: ^\d{2}\.\d{2}$

If x is word character ^\w{2}\.\w{2}$

Good tools for Regex:

  • RegExr (Online, i don't think it is C# Regex dialect but still very useful)
  • Regex Tester (Visual Studio Extension)

In my experience Regex is not hard, but the syntax is very unintuitive you really have to memorize it or have a good tool.

On the bright side there are only a couple of instructions/keywords that you need to know but there are not too many for the common usages.

I keep a small test project with Regexes so I dont have to remember them. In the above regexes the following is done:

  • '^'匹配字符串的开头,如果您的字符串可以出现在字符串的中间,则需要将其删除,并且可能将其替换为匹配字边界的\ b
  • \ d匹配数字
  • \ w匹配任何单词字符(字母数字和下划线).
  • {2}告诉上一场比赛必须出现两次.您可以在此处使用许多变体.
  • \.匹配'.' 它需要用'\'进行转义.已经被Regex使用(一次隐含)
  • '$'匹配字符串的结尾(如果您的字符串可以出现在字符串的中间,则替换为\ b)