【发布时间】:2021-03-17 14:47:57
【问题描述】:
示例字符串:https://test-welcome123.com/ablcv#$2 我只想验证 https://test-welcome.com 这部分。 /ablcv#$2 这部分我不想验证。 要求:
- 网址 (https://test-welcome123.com) 应为小写字母、数字、点 (.) 和连字符 (-)。
- 在斜杠 (/) 之后可以是任何内容。
我正在使用 Unicode 正则表达式来验证字符串。 我能够验证 URL。但不明白如何避免验证斜杠(/)后的字符串。
^(https://)(((([\p{Ll}\p{N}]|[\p{Ll}\p{N}][\p{Ll}\p{N}\-]*[\p{Ll}\p{N}])\.)*([\p{Ll}\p{N}]|[\p{Ll}\p{N}][\p{Ll}\p{N}\-]*[\p{Ll}\p{N}])))+$
我需要在输入 URL 后避免验证。我该怎么做?
【问题讨论】: