 <p>Here is a sample in JS to match your require, another language should the same.</p> <pre><code>/^gs:\/\/(.+?)\/(.+)$/ </code></pre> <p>Check result <a href="http://scriptular.com/#%5Egs%3A%5C%2F%5C%2F(.%2B%3F)%5C%2F(.%2B)%24%7C%7C%7C%7C%7C%7C%7C%7C%5B%22gs%3A%2F%2Fbucket%2Ffolder1%2Ffolder2%2Ftest.csv%22%5D" rel="nofollow">here</a> </p>