全部!我有這樣的文字「一些文字與uri http://test.com等字。」我需要使用一個正則表達式來獲取部分uri。正則表決:文本的URI部分
我試試這個:
string text = "Some text with uri http://test.com and other words.";
string pattern = @"\b(\S+)://([^:]+)(?::(\S+))?\b";
MatchCollection matches = Regex.Matches(text, pattern);
和它的作品,當我寫 「與URI http://test.com一些文本」 或 「字1 http://test.com:5000 WORD2」。
哪裏錯了?
什麼不工作?你說「它有效」。 – payne 2011-02-12 01:43:27
我的猜測是,這是返回`http://test.com和其他單詞。「是嗎? – 2011-02-12 02:38:41