Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何创建一个正则表达式来验证这样的函数:
=TRIMESTER(1,2,2008)
第一个参数应该是任何整数。第二个参数是一个不应该大于 4 的整数。第三个参数是年份(4 位)
这是你想要的吗?
=TRIMESTER\(\d+,[1-4],\d{4}\)
它匹配第一个参数的任意数字(至少一个),第二个参数匹配 1 到 4(包括)之间的任意数字,最后一个参数匹配任意四位数字。
或者,如果您只想验证第二个参数,则:
[1-4]
但我更喜欢简单的比较,像这样:
AND(x >= 1; x <= 4)