[英]Extract substring with Regex
我试图用正则表达式提取一个子串,但是我遇到了一些麻烦...
字符串是从一列字符串构建的,我只需要第四列
string stringToExtractFrom = "289 120 00001110 ??
4Control@SimApi@@QAEAAV01@ABV01@@Z = ??4Control@SimApi@@QAEAAV01@ABV01@@Z
(public: class SimApi::Control & __thiscall SimApi::Control::operator=(class
SimApi::Control const &))"
string pattern = @"\s+\d+\s+\d+\s+\S+\s(.*)\=";
RegexOptions options = RegexOptions.Multiline;
Regex regX = new Regex(pattern, options);
Match m = regX.Match(stringToExtractFrom);
while (m.Success)
{
Group g = m.Groups[1];
defData += g+"\n";
m = m.NextMatch();
}
这是通缉的字符串: 4控制@ SimApi @@ QAEAAV01 @ ABV01 @@ž
当我得到我想要的子字符串时,它下面的字符串有效
1 0 00002E00 0ADOFactory @ SimApiEx @@ QAE @ ABV01 @@ Z = 0ADOFactory @ SimApiEx @@ QAE @ ABV01 @@ Z(公共:__thiscall SimApiEx :: ADOFactory :: ADOFactory(SimApiEx :: ADOFactory const&) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.