30 inline 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),
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_);
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
bool set(const char *pattern, bool ignoreCase=false)
Compile pattern into a regular expression, optionally ignore case.
static bool is_meta(const char c) noexcept
Test if character is a regex meta-character.
unsigned ngroups() const
The number of capture groups for a non-empty, non-negated expressions.
regExpCxx()
Default construct.
bool empty() const noexcept
True if expression is empty.
bool match(const std::string &text) const
True if the regex matches the entire text.
bool clear()
Clear expression.
bool negate(bool on) noexcept
Change pattern negation, return previous value.
graph_traits< Graph >::vertices_size_type size_type
bool operator()(const std::string &text) const
Perform match on text.
void swap(regExpCxx &rgx)
Swap contents.
void operator=(const regExpCxx &rgx)
Copy assignment.
bool exists() const noexcept
True if expression is non-empty.
const dimensionedScalar c
Speed of light in a vacuum.
static int grammar
The default grammar (extended | ECMAScript).
bool search(const std::string &text) const
Return true if the regex was found within the text.
std::string::size_type find(const std::string &text) const
Find position within the text.
bool negated() const noexcept
True if pattern matching is negated.
Wrapper around C++11 regular expressions with some additional prefix-handling. The prefix-handling is...