Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of URL parsing PCRE regex for .NET

Tags:

regex

There's a PCRE regex for extracting URLs posted here: http://daringfireball.net/2009/11/liberal_regex_for_matching_urls

\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))

What would need to be changed to make it compatible with regex in .NET?

like image 599
John Sheehan Avatar asked Dec 10 '25 22:12

John Sheehan


1 Answers

Looking at in Regexbuddy now. So far, the only issue is the [:punct:] - doesn't look like .NET supports POSIX character classes.

EDIT - double clicking on the offender gave me this:

\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^\p{P}\s]|/)))

like image 65
Nicolas Webb Avatar answered Dec 12 '25 15:12

Nicolas Webb