#regex用于验证URL验证



我确实有以下URL

https://domain.xyz/version/path/node

节点可以更改,但格式必须是相同的

#regex '[0-9a-z]{9}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}'

我已经阅读了文档并查找了示例,但我无法使其发挥作用。

我该如何在空手道中做到这一点?

只需执行以下操作:

* def myUrl = 'https://domain.xyz/version/path/blah-blah'
* def pos = myUrl.lastIndexOf('/')
* def node = myUrl.substring(pos + 1)
* match node == '#regex [0-9a-z]{4}-[0-9a-z]{4}'

最新更新