[英]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.