我想将这些关键词之一之后的任何案文归为几句。
投入:/send 1 at 11:00pm for 3min
预期结果:postNumber = 1, sentAt = 11:00pm,dur = 3min
投入:/send 1 for 3min
预期结果:postNumber = 1,dur = 3min
投入:/send 1 at 11:00p
预期结果:postNumber = 1, sentAt = 11:00pm
投入:/send 1 to 11:00p
预期结果:postNumber = 1, 直至 = 11:00pm
投入:/send 1 for 3min at 11:00 pm
预期结果:postNumber = 1, sentAt = 11:00 pm,dur = 3min
投入:/send 1 at 11am for 1 h
预期结果:postNumber = 1, sent = 11am, 有效期 = 1 h
我先做了以下小节,但可以预示如何使之符合关键词的投入顺序。
?
I tried to add positive lockahead but it matched all the digits in the first group
(?<postNumber>d+)(?=(?: at (?<timeToSend>.*)))?(?=(?: for (?<duration>.*)))?(?=(?: until (?<until>.*)))?