How to match urls with 3 slashes with REGEXMATCH function in Goggle Spreadsheets

Viewed 37

I have a list of URLS in google spreadsheet, and I'd like to match urls that contain 3 slashes (home page ulrs). I tried to use this formula but it doesn't match correctly

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

Use

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

Note [^/]*, zero or more characters different from /.

EXPLANATION

--------------------------------------------------------------------------------
  ^                        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
Related