43 TString s1(
"lekkere pepernotenkoek");
44 TPRegexp r1(
"\\bpeper(\\w+)koek\\b");
48 cout << s1(r1) << endl;
52 r1.Substitute(s1,
"wal$1boom");
58 TString s2(
"one two three");
59 TPRegexp(
"^([^ ]+) +([^ ]+)").Substitute(s2,
"$2 $1");
68 TString s3(
"on 09/24/1959 the world stood still");
69 TPRegexp(
"\\b(\\d{1,2})/(\\d{1,2})/(\\d{4})\\b").Substitute(s3,
"$2-$1-$3");
83 TString s4(
"http://fink.sourceforge.net:8080/index/readme.html");
84 TObjArray *subStrL = TPRegexp(
"^(\\w+)://[^/]+:(\\d+)/$").MatchS(s4);
85 const Int_t nrSubStr = subStrL->GetLast()+1;
87 const TString proto = ((TObjString *)subStrL->At(1))->GetString();
88 const TString port = ((TObjString *)subStrL->At(2))->GetString();
89 cout <<
"protocol: " << proto <<
" port: " << port << endl;
110 TString s5(
"fons.rademakers@cern.ch");
111 TPRegexp r5(
"^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
112 cout <<
"Check if the email address \"" << s5 <<
"\" is valid: " << (r5.MatchB(s5) ?
"TRUE" :
"FALSE") << endl;
119 TString s6(
"neutron proton electron neutron");
120 TPRegexp(
"(n\\w+n)").Substitute(s6,
"neutrino",
"g");