0
渡されたテキストパラメータにURLが含まれている場合、trueを返すメソッドを作成しようとしています。ここで私はこれまで持っているものです。正規表現を使用してURLを含むテキストを検索するにはどうすればよいですか?
private bool TextContainsUrl(string text)
{
Regex rgx = new Regex(@"((http|ftp|https|www)://)?([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?");
bool match = rgx.IsMatch(text);
return match;
}
私は好きそれを呼ぶかもしれない:
TextContainsUrl("here is a text with url http://something.net bla bla.");
または
TextContainsUrl("here is a text with no url bla bla.");
問題は、戻り上記の両方のコールが真ということ、です。
私はここで間違っていますか?
「www://」で始まるURIスキームはありません。現在登録されているすべてのURIスキームについては、こちらをご覧ください:https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml#uri-schemes-1 – antiduh