30inline std::regex::flag_type Foam::regExpCxx::syntax()
36 ? std::regex::ECMAScript
37 : std::regex::extended
47 || (c ==
'*' || c ==
'+' || c ==
'?')
48 || (c ==
'(' || c ==
')' || c ==
'|')
49 || (c ==
'[' || c ==
']')
56 const std::string& str,
61 for (
const char c : str)
63 if (quote && c == quote)
98 re_(std::move(rgx.re_)),
108 const bool ignoreCase
114 set(pattern, ignoreCase);
120 const std::string& pattern,
121 const bool ignoreCase
127 set(pattern, ignoreCase);
147 return (ctrl_ == ctrlType::NEGATED);
153 bool old(ctrl_ == ctrlType::NEGATED);
159 ctrl_ = ctrlType::NEGATED;
164 ctrl_ = ctrlType::NORMAL;
174 return ctrl_ == ctrlType::NORMAL ? re_.mark_count() : 0;
180 return ctrl_ && ((re_.flags() & std::regex::icase) == std::regex::icase);
204 std::swap(ctrl_, rgx.ctrl_);
215 (pattern ? std::char_traits<char>::length(pattern) : 0),
232inline std::string::size_type
239 return std::string::npos;
241 else if (text.empty())
243 if (ctrl_ == ctrlType::NEGATED)
249 return std::string::npos;
256 const bool ok = std::regex_search(text, mat, re_);
258 if (ctrl_ == ctrlType::NEGATED)
267 return mat.position(0);
271 return std::string::npos;
283 const bool ok = (!text.empty() && std::regex_search(text, re_));
285 return (ctrl_ == ctrlType::NEGATED) ? !ok : ok;
297 const bool ok = (!text.empty() && std::regex_match(text, re_));
299 return (ctrl_ == ctrlType::NEGATED) ? !ok : ok;
305 const std::string& text,
316 return std::regex_match(text, matches, re_);
Wrapper around C++11 regular expressions with some additional prefix-handling. The prefix-handling is...
bool empty() const noexcept
True if expression is empty.
regExpCxx()
Default construct.
std::string::size_type find(const std::string &text) const
Find position within the text.
bool set(const char *pattern, bool ignoreCase=false)
Compile pattern into a regular expression, optionally ignore case.
bool exists() const noexcept
True if expression is non-empty.
void operator=(const regExpCxx &rgx)
Copy assignment.
bool match(const std::string &text) const
True if the regex matches the entire text.
bool search(const std::string &text) const
Return true if the regex was found within the text.
bool negated() const noexcept
True if pattern matching is negated.
bool clear()
Clear expression.
bool negate(bool on) noexcept
Change pattern negation, return previous value.
bool operator()(const std::string &text) const
Perform match on text.
static bool is_meta(const char c) noexcept
Test if character is a regex meta-character.
void swap(regExpCxx &rgx)
Swap contents.
static int grammar
The default grammar (extended | ECMAScript).
unsigned ngroups() const
The number of capture groups for a non-empty, non-negated expressions.