C# 带空格的Regexp

C# 带空格的Regexp,c#,regex,C#,Regex,我有这样的regexp模式: ^[a-zA-Z0-9]+\s(INV|FINAL)\s([0,1]?\d{1}\s(([0-2]?\d{1})|([3][0,1]{1}))\s(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3})))(\s{1})\d+$ 此模式应验证文档名称是否正确 这样的文档名称应与此模式匹配: 1207181 FINAL 12 13 12 1533 一开始,只是数字,就像id一样 下一个空间 下一个INV或最后一个单词 格式为dd mm

我有这样的regexp模式:

^[a-zA-Z0-9]+\s(INV|FINAL)\s([0,1]?\d{1}\s(([0-2]?\d{1})|([3][0,1]{1}))\s(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3})))(\s{1})\d+$
此模式应验证文档名称是否正确 这样的文档名称应与此模式匹配:

1207181 FINAL 12 13 12 1533
一开始,只是数字,就像id一样

下一个空间

下一个INV或最后一个单词

格式为dd mm yy的下一个日期

接下来是一些数字

有人能帮我解决这个问题吗?

您正在搜索:

^(\d+)\s(INV|FINAL)\s(0[1-9]|[12]\d|3[01])\s(0[1-9]|1[0-2])\s(\d{2})\s(\d+)$
说明:

^                      start at the beginning of the string
(\d+)                  capture any digit
\s                     one whitespace
(INV|FINAL)            captrue INV or FINAL
0[1-9]                 a 0 and a digit from 1 to 9
[12]\d                 a 1 or a 2 and a digit
3[01]                  a 3 and a 0 or a 1
(0[1-9]|[1-2]\d|3[01]) capture a digit from 01 to 31
(0[1-9]|1[0-2])        capture a 0 and a digit from 1 to 9 or a 1 and a digit from 0 to 2 | so capture a digit from 01 to 12
(\d{2})                capture two digits
$                      stop at the end of the string

它与1207181 FINAL 12 13 12 1533不匹配,因为有13。

regexp有很多变体,您在哪个应用程序或语言中使用它们?问题是这个regexp无法正常工作。有人可以根据我的条件帮我编写regexp吗?@Alex:如果您需要帮助,请说明到底是什么问题。如果您希望有人为您编写正则表达式,这不是正确的网站。