开发者

How do I extract string from pattern to pattern?

I am trying to extract a string between two patterns from another string in C++.

Example of input: "C++ is not that easy"

Pattern1: "C++"

Pattern2: "that"

Result: " is not "

I would like to loop this operation to extract all matchin开发者_如何转开发g strings from binary file later.


The best way for this is to use regular expressions.

You can read more about it here


You can use string::find() to find the position of each pattern within the input, string::length() to find the end position of the first pattern (since find() gives the start),and then string::substr() to extract the substring between those positions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜