-2

I've a regex to extract an url but sometime it doesn't work. Here is my regex

@"((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\. _~%]*)*"

And here an url that doesn't work http://myaddress.domain.com/Knowledge/Legal_Sources/NL/myaddress/Omzendbrieven/repo/machin MÚdecin-conseil Le Ressort.doc

I've this back http://myaddress.domain.com/Knowledge/Legal_Sources/NL/myaddress/Omzendbrieven/repo/machin%20M

ROMANIA_engineer
  • 51,252
  • 26
  • 196
  • 186
user1898765
  • 313
  • 1
  • 6
  • 17

1 Answers1

0

Try this fiddle

The regex you are looking for is @"^(https?|ftp|file):\/\/[\w.\-]+(\.[\w\-]+)[/#?].*$"

Kristijan Iliev
  • 4,827
  • 9
  • 28
  • 46