[Python] Python: using split() to split a string at 2 separate points

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have a string that I need to split at 2 separate parts, but all I find is how to split the string using identifiers like "," and other punctuation.

    string = "<p>The brown dog jumped over the... <a href="https://google.com" target="something">... but then splashed in the water<p>

    hyperlink = re.split(r'(?=https)',string)

    print(hyperlink[0])



    In the example above, I need to extract just the url in the string "https://google.com" then print out. However, I can only find out how to split the string at "https", so everything past the url comes with it.

    I hope this makes sense. After a bunch of searching and testing I can figure out how to do this.

    Continue reading...

Compartilhe esta Página