Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'd like to get urls in strings. For example I got:

"You got to see this link[http://some.link/you/have?to=see]"

I think theses are non-valid url characters: "'()[]{}

share|improve this question
1  
Can you please clarify more on your question and show us what you've tried until now? –  Allendar Mar 9 at 18:14
1  
They are valid URL characters. Is your strings all include URLs between square brackets [] or is it just an example? –  Selcuk Mar 9 at 18:15
    
@Selcuk This is just an example –  lanodan Mar 9 at 18:20
add comment

1 Answer 1

Your regex to find the URL would look something like this:

'https?://[^\"\'\(\)\[\]\{\}]+'

which is basically just looking for a string starting with 'http' or 'https' and then '://' and then all characters that follow that are not "'()[]{}

share|improve this answer
    
Not working with: "You got to see this link[http://some.link/you/have?to=see]".split('https?://[^\"\'\(\)\[\]\{\}]+') Maybe I've to use re.compile ? –  lanodan Mar 9 at 18:28
    
try re.findall('https?://[^\"\'\(\)\[\]\{\}]+', "You got to see this link[http://some.link/you/have?to=see]")[0] this works for me, just tried it –  SS781 Mar 9 at 20:51
    
Did this work for you? –  SS781 Mar 10 at 15:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.