我有一个正则表达式,它应该*拾取到一个字符串:
输入字符串:
Vmid Name File Guest OS Version Annotation
3 TinyCore Linux [datastore1] TinyCore Linux/TinyCore Linux.vmx otherLinuxGuest vmx-08
4 Debain6 [datastore1] Debain6/Debain6.vmx ubuntu64Guest vmx-08
正则表达式:
[]][ A-Za-z /.]+.vmx [ ]
正则表达式匹配字符串的以下部分:
] TinyCore Linux/TinyCore Linux.vmx
但也应该匹配:
] Debain6/Debain6.vmx
我的代码如下:
private void regexTest_Click(object sender, EventArgs e)
{
Regex regex = new Regex("[]][ A-Za-z /.]+.vmx [ ]");
MatchCollection match = regex.Matches(input);
foreach (Match matchvalue in match)
{
MessageBox.Show(matchvalue.ToString());
}