我试图断言一个匹配任何主机的正则表达式,并且基本上匹配 url 以 /profile/documents/<uuid>
下面的这个正则表达式完全 匹配,/profile/documents/<uuid>
但我如何修改这个正则表达式以匹配以 结尾的任何内容/profile/documents/<uuid>
?
expect(res.headers.location).to.match(/^\/profile\/documents\/[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i) // Regex for /profile/documents/:uuid
我希望匹配的示例是:
http://localhost:3000/profile/documents/8ce825b7-b8c2-468b-a4c8-88eedea5b4c2
http://127.0.0.1/49943/profile/documents/8ce825b7-b8c2-468b-a4c8-88eedea5b4c2
简单 - 只需^
在开始时删除。(这是相匹配的字符串的开始,所以只有/profile/document/<uuid>
将已匹配-删除它匹配任何字符串结尾的/profile/document/<uuid>
):
/\/profile\/documents\/[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句