45 EST_Regex exclamation(
"\\(wow\\|yey\\|lo\\)[^a-z]");
47 cout << example <<
"\n";
49 printf(
"stdio version %s\n", (
const char *)example);
52 if (example.contains(exclamation))
53 cout <<
"\nYes, it contains a match for " << exclamation <<
"\n";
63 cout <<
"match was '" << example.
at(start_br[0], end_br[0]- start_br[0]) <<
"'\n";
66 cout <<
" word was '" << example.
at(start_br[1], end_br[1]- start_br[1]) <<
"'\n";
73 EST_Regex url_re(
"\\([a-z]*\\)://\\([^/]*\\)\\(.*\\)");
74 EST_String target(
"protocol=\\1 host=\\2 path=\\3 dummy=\\6");
76 cout <<
"processing '" <<source <<
"'\n";
77 if (source.matches(url_re,
81 target.
subst(source, start_br, end_br);
82 cout <<
" gives '" << target <<
"'\n";
85 cout <<
"No match for URL RE\n";
87 EST_String complex(
"what if I don't like 'hello world'?");
90 EST_String unquoted(quoted.unquote_if_needed(
'\''));
93 cout <<
"start with \"" << complex <<
"\"\n";
94 cout <<
" quoted \"" << quoted <<
"\"\n";
95 cout <<
" unquoted \"" << unquoted <<
"\"\n";
100 cout <<
" gubbins \"" << gubbins <<
"\"\n";
int subst(EST_String source, size_t(&starts)[EST_Regex_max_subexpressions], size_t(&ends)[EST_Regex_max_subexpressions])
Substitute the result of a match into a string.
EST_String quote_if_needed(const char quotec) const
Return in quotes if there is something to protect (e.g. spaces)
A Regular expression class to go with the CSTR EST_String class.
#define EST_Regex_max_subexpressions
#define EST_STRING_ERR_IDX
EST_String at(int from, int len=0) const
Return part at position.