簡體   English   中英

正則表達式以提取網站地址

[英]regular expression to extract the website address

我正在嘗試從給定的文本中提取網站(例如http://wwww.yogacenter.com:4355 )。 但是我沒有與以下代碼匹配。 有什么建議么 ?

        string pattern = @"\b(\S+)://(S+)(?::(\S+))?\b";
        string text = "i have just found this http://wwww.yogacenter.com:4355 at my  place.It's a http:// site.";
        MatchCollection mc = Regex.Matches(text, pattern);
        foreach (Match item in mc)
        {
            Console.WriteLine(item.Value);
        }

“ \\ b(\\ S +)://(S +)(?::(\\ S +))?\\ b”我相信您的問題在於第二個S之前缺少反斜杠

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM