Reputation: 323
I'm trying to use a regex to get an url but i miss the end of the url here is an example of string containing an url
<div class=\"ExternalClassC7001553FFC442DD9B99547999723C7B\">http://bazar.flow.be/Knowledge/Legal/FR/Ina/Circul/Circul BB adm. 2014/circ_bb_p_2014_xxx.doc</div>
I've to get this in output:
http://bazar.flow.be/Knowledge/Legal/FR/Ina/Circul/Circul BB adm. 2014/circ_bb_p_2014_xxx.doc
For now, i use this regex that return me: "http://bazar.flow.be/Knowledge/Legal/FR/Ina/Circul/Circul"
@"((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*"
thanks for a solution
Upvotes: 0
Views: 63
Reputation: 67968
((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*([^<]+)*
Try this.See demo.
http://regex101.com/r/hQ1rP0/83
Upvotes: 0
Reputation: 91375
Just add space in last character class, and you can simplify your regex to:
(?:(?:https?|ftp|file)\://|www\.)[A-Za-z0-9.-]+(?:/[\w?&=;+!'()*.~% -]*)*
Upvotes: 1
Reputation: 7466
Just add a backslash and a space at the end of your regex:
@"((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%\ ]*)*"
Upvotes: 0
Reputation: 11116
include a space in between somewhere:
@"((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\. _~%]*)*"
|
added space here
Upvotes: 1