精華區beta RegExp 關於我們 聯絡資訊
/* 聽說註明使用的語言、環境 * 問題有可能較容易被解決... */ 我的資料長得像 <A><B>xxxxx1xxx</B></A><A><B>xxxxx2xxx</B></A><A><B>xxxxx3xxx</B></A> 我的寫法(C#) string input = "<A><B>xxxxx1xxx</B></A><A><B>xxxxx2xxx</B></A><A><B>xxx xx3xxx</B></A>"; string pattern = @"(<A>.*</A>)"; // 規則字串 Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); MatchCollection matches = regex.Matches(input); // 將比對後集合傳給 MatchCollection 可是傳回的結果會是一組(原先的資料),我希望可以回傳的結果是有三組符合 分別是 <A><B>xxxxx1xxx</B></A> <A><B>xxxxx2xxx</B></A> <A><B>xxxxx3xxx</B></A> 嘗試改了很久的pattern寫法都無法成功~希望大大們幫忙,感謝^^ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.169.119
blackkaku:<A.*?</A> 02/02 10:38
fantic:謝謝b大~^_^ 02/02 10:55