36 #include "EST_String.h"
43 EST_Regex exclamation(
"\\(wow\\|yey\\|lo\\)[^a-z]");
45 cout << example <<
"\n";
47 printf(
"stdio version %s\n", (
const char *)example);
50 if (example.contains(exclamation))
51 cout <<
"\nYes, it contains a match for " << exclamation <<
"\n";
54 int start_br[EST_Regex_max_subexpressions];
55 int end_br[EST_Regex_max_subexpressions];
58 if (example.search(exclamation, len, 0, start_br, end_br)>=0)
61 cout <<
"match was '" << example.at(start_br[0], end_br[0]- start_br[0]) <<
"'\n";
64 cout <<
" word was '" << example.at(start_br[1], end_br[1]- start_br[1]) <<
"'\n";
70 EST_String source(
"http://www.cstr.ed.ac.uk/speech_tools");
71 EST_Regex url_re(
"\\([a-z]*\\)://\\([^/]*\\)\\(.*\\)");
72 EST_String target(
"protocol=\\1 host=\\2 path=\\3 dummy=\\6");
74 cout <<
"processing '" <<source <<
"'\n";
75 if (source.matches(url_re,
79 target.subst(source, start_br, end_br);
80 cout <<
" gives '" << target <<
"'\n";
83 cout <<
"No match for URL RE\n";
85 EST_String complex(
"what if I don't like 'hello world'?");
87 EST_String quoted(complex.quote_if_needed(
'\''));
88 EST_String unquoted(quoted.unquote_if_needed(
'\''));
91 cout <<
"start with \"" << complex <<
"\"\n";
92 cout <<
" quoted \"" << quoted <<
"\"\n";
93 cout <<
" unquoted \"" << unquoted <<
"\"\n";
98 cout <<
" gubbins \"" << gubbins <<
"\"\n";