Tokenize using a POSIX extended regular expression.
- Parameters
-
[in] | exp | the delimiter expression |
[in] | imatch | false to include the actual matches in the result |
[in] | icase | true to ignore case sensitivity |
- Returns
- the list of tokens (heap allocated)
- Exceptions
-
Definition at line 642 of file string.cpp.
References csdbg::chain< T >::add(), cstr(), likely, m_data, m_length, match(), string(), and unlikely.
Referenced by csdbg::parser::parse(), and csdbg::plugin::resolve().
644 chain<string> *tokens = NULL;
650 tokens =
new chain<string>;
653 i32 flags = REG_EXTENDED;
657 i32 retval = regcomp(®exp, exp.cstr(), flags);
659 i32 len = regerror(retval, ®exp, NULL, 0);
661 regerror(retval, ®exp, errbuf, len);
664 "failed to compile regexp '%s' (regex errno %d - %s)",
675 bool found = !regexec(®exp,
m_data + offset, 1, &match, 0);
685 i32 bgn = match.rm_so;
686 i32 end = match.rm_eo;
688 throw exception(
"logic error in regular expression '%s'", exp.cstr());
695 word =
new string(
"%.*s", end - bgn,
m_data + offset + bgn);
711 else if (
likely(offset <= len) ) {
char i8
8-bit signed integer
string(u32=0)
Object constructor.
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
virtual bool match(const string &, bool=false) const
Match against a POSIX extended regular expression.
int i32
32-bit signed integer
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
u32 m_length
Character count.