title: Replace first occurrence of string in Python
body: <p>I have some sample string. How can I replace first occurrence of this string in a longer string with empty string?</p>
  
  <pre><code>regex = re.compile('text')
  match = regex.match(url)
  if match:
      url = url.replace(regex, '')
  </code></pre>