MCPcopy Create free account
hub / github.com/Kitware/ParaView / ReplaceStringUsingRegex

Function ReplaceStringUsingRegex

Remoting/Views/vtkSMSelectionHelper.cxx:50–72  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

48vtksys::RegularExpression RegExNodeIdInExpression = "[a-zA-Z0-9]+";
49//------------------------------------------------------------------------------
50void ReplaceStringUsingRegex(std::string& source, vtksys::RegularExpression& regex,
51 const std::string& replace, const std::string& with)
52{
53 // find all matches
54 std::vector<std::string> matches;
55 for (size_t next = 0; regex.find(source.substr(next)); next += regex.end())
56 {
57 const auto mathWord = source.substr(next + regex.start(), regex.end() - regex.start());
58 if (mathWord == replace)
59 {
60 matches.push_back(mathWord);
61 }
62 }
63 // replace all matches
64 for (const auto& match : matches)
65 {
66 const auto pos = source.find(match);
67 if (pos != std::string::npos)
68 {
69 source.replace(pos, match.length(), with);
70 }
71 }
72}
73}
74
75//------------------------------------------------------------------------------

Callers 1

CombineSelectionMethod · 0.85

Calls 5

substrMethod · 0.80
push_backMethod · 0.80
findMethod · 0.45
endMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected