我的弱点是正则表达式,我希望有人可以帮助我。我有一个字符串:
string comment = myOrder[Original Tel Number: Some string that can be any size basically\nHome: 94036\nPostal Code: B4]
现在我试图像这样分解这个字符串:
var match = Regex.Match( comment, @"Original Tel Number:\s(\w+)\s*\nHome:\s(\w+)\s*\nPostal Code:\s(\w+)" );
if ( match.Success )
{
inputOrder.BaseHomeTel = match.Groups[1].Value;
inputOrder.Home = match.Groups[2].Value;
inputOrder.PostalCode = match.Groups[3].Value;
}
但它似乎永远不匹配,我在这里做错了什么。