-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
  • 54,432
  • 29
  • 203
  • 199
user1898765
  • 323
  • 1
  • 6
  • 18

1 Answers1

0

Try this fiddle

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

Kristijan Iliev
  • 4,901
  • 10
  • 28
  • 47