Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在解析 html Web 文档时,我最终得到的字符串可能如下所示:
"钢铁之刃 \n \n \n \n \n典型 - 你的情况 \n 28\n 347\n \n $8.47 \n \n1234567891011121314151617181920212223242526272829303132"
我在这个字符串中想要的只是这些值:
我怎样才能轻松地解析字符串而不必执行多个string.Replaceor string.Split?
string.Replace
string.Split
如果你事先知道格式,你可以写一个正则表达式来解析它。
如果你知道格式,你可以这样做:
string first = yourString.Split('\n')[0]; //Blades of Steel string second = yourString.Split('\n')[9]; //$8.47