12#ifndef MCRL2_UTILITIES_DETAIL_SEPARATE_KEYWORD_SECTION_H
13#define MCRL2_UTILITIES_DETAIL_SEPARATE_KEYWORD_SECTION_H
16#include <boost/algorithm/string/join.hpp>
17#include <boost/algorithm/string/trim.hpp>
29 std::pair<std::string, std::string>
separate_keyword_section(
const std::string& text1,
const std::string& keyword,
const std::vector<std::string>& all_keywords,
bool repeat_keyword =
false)
31 std::string text = boost::trim_copy(text1);
32 std::ostringstream out1;
33 std::ostringstream out2;
35 std::string regex_keyword =
"\\b" + keyword +
"\\b";
37 std::vector<std::string> v = all_keywords;
38 v.erase(std::remove(v.begin(), v.end(), keyword), v.end());
39 for (std::string& s: v)
41 s =
"(\\b" + s +
"\\b)";
43 std::string regex_other_keywords = boost::algorithm::join(v,
"|");
46 if (text.find(keyword) != 0 && !specs.empty())
48 out2 << specs.front() << std::endl;
49 specs.erase(specs.begin());
51 for (
const std::string& spec: specs)
59 out1 <<
"\n" << keyword;
61 out1 <<
" " << v.front();
62 out2 << spec.substr(v.front().size());
65 std::string s1 = out1.str();
70 s1 = keyword +
"\n" + s1;
73 return std::make_pair(s1 +
"\n", out2.str() +
"\n");
std::pair< std::string, std::string > separate_keyword_section(const std::string &text1, const std::string &keyword, const std::vector< std::string > &all_keywords, bool repeat_keyword=false)
std::vector< std::string > regex_split(const std::string &text, const std::string &sep)
Split a string using a regular expression separator.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
String manipulation functions.