MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / HandleRegexSubString

Method HandleRegexSubString

lib/macro/macro-action-variable.cpp:79–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void MacroActionVariable::HandleRegexSubString(Variable *var)
80{
81 const auto curValue = var->Value();
82 auto regex = _subStringRegex.GetRegularExpression(_regexPattern);
83 if (!regex.isValid()) {
84 return;
85 }
86
87 auto it = regex.globalMatch(QString::fromStdString(curValue));
88 const auto regexMatchIndex = _regexMatchIdx.GetValue() - 1;
89 for (int idx = 0; idx < regexMatchIndex; idx++) {
90 if (!it.hasNext()) {
91 return;
92 }
93 it.next();
94 }
95
96 if (!it.hasNext()) {
97 return;
98 }
99
100 auto match = it.next();
101 var->SetValue(match.captured(0).toStdString());
102}
103
104void MacroActionVariable::HandleFindAndReplace(Variable *var)
105{

Callers

nothing calls this directly

Calls 5

GetRegularExpressionMethod · 0.80
GetValueMethod · 0.80
ValueMethod · 0.45
nextMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected