使用正则表达式C ++进行搜索(Searching using regular expressions C++)
我正在使用Boost.Regex来实现这样的目标:搜索“|” 然后取“|”的左侧部分 并把它放在一个字符串,与右边部分相同:
string s1; string s2; who | sort在这之后,s1应该是“谁”,而s2应该是“排序”。 如果我记得很好,它在Python中是可行的,我怎么能在Boost中使用正则表达式呢?
谢谢。
I'm using Boost.Regex to achieve something like this: search for a "|" and then take the left part of the "|" and put it a string, same with the right part:
string s1; string s2; who | sortAfter this s1 should be "who" and s2 shoudl be "sort". If I remember good, it was posible in Python, how can I do it using regular expressions in Boost ?
Thank you.
最满意答案
#include <boost/algorithm/string.hpp> std::vector<std::string> strs; boost::split(strs, "string to split", boost::is_any_of("|"));用C ++拆分一个字符串?
#include <boost/algorithm/string.hpp> std::vector<std::string> strs; boost::split(strs, "string to split", boost::is_any_of("|"));Split a string in C++?
更多推荐
发布评论