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.
加载中,请稍侯......
精彩评论