如何在Goggle电子表格中使用REGEXMATCH功能将URL与3个斜杠匹配



我在谷歌电子表格中有一个URL列表,我想匹配包含3个斜杠的URL(主页URL(。我试着使用这个公式,但它与不匹配

=REGEXMATCH(B2;"^https?://.*?.[a-z]{2,6}/$")

使用

=REGEXMATCH(B2;"^https?://[^/]*.[a-zA-Z]{2,6}/$")

注意[^/]*,零个或多个不同于/的字符。

解释

--------------------------------------------------------------------------------
^                        the beginning of the string
--------------------------------------------------------------------------------
http                     'http'
--------------------------------------------------------------------------------
s?                       's' (optional (matching the most amount
possible))
--------------------------------------------------------------------------------
://                      '://'
--------------------------------------------------------------------------------
[^/]*                    any character except: '/' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
.                       '.'
--------------------------------------------------------------------------------
[a-zA-Z]{2,6}            any character of: 'a' to 'z', 'A' to 'Z'
(between 2 and 6 times (matching the most
amount possible))
--------------------------------------------------------------------------------
/                        '/'
--------------------------------------------------------------------------------
$                        before an optional n, and the end of the
string

最新更新