求助,关于截取字符串的问题
字符串:
<option value=''> Please Select Color </option><option value='The Same as Picture'> The Same as Picture</option><option value='White'> White</option><option value='Ivory'> Ivory</option><option value='Champagne'> Champagne</option><option value='Pink'> Pink</option><option value='Silver'> Silver</option>
想处理成:
White|Ivory|Champagne|Pink|Silver
求助大家了,谢谢。
[解决办法]
用正则
[解决办法]
StreamReader reader = new StreamReader("c:\\temp\\1.txt",Encoding.Default); string source = reader.ReadToEnd(); Regex reg = new Regex(@"(?is)(?<=value=')[\S]+(?=')"); MatchCollection mc = reg.Matches(source); foreach (Match m in mc) { MessageBox.Show(m.Value); }