Regex modification
I am absolutely stuck when it comes to regex. I have been trying to modify the following expression to match URLs that begin with "www". It already matches URLs that begin with http, ftp, and https but not just plain www. I have not had much success on my own.
Regex.IsMatch(text, @"(^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/开发者_Python百科~\+#]*[\w\-\@?^=%&/~\+#])?)")
Make this...
(http|ftp|https):\/\/
into this...
((http|ftp|https):\/\/|www\.)
@Amber provided a direct answer to your question (so I gave it a +1) but I would like to point out another fact you should be thinking of.
Detecting URLs in free text isn't as trivial as one may think. Jeff Atwood has presented the problem very well in his blog post. I suggest you read about it and get to know the problem.
精彩评论