///////////////////////////////////////////////////////////////////// // regexpr.cpp // // Sample using TRegexp container class // George Cross, Borland C++ Tech Support // April 1996 ///////////////////////////////////////////////////////////////////// #include #include #include int main(){ // //Declare a TRegexp variable representing any word at the //beginning of a line starting with a capital 'S' // TRegexp TrivialExpression( "^S[a-z]*" ); // //Variables to work with // string TrivialTextString; size_t StringLength; size_t PositionInString; cout << "Please type 'Some_text'" << endl; cin >> TrivialTextString; PositionInString = TrivialExpression.find(TrivialTextString, &StringLength); if (PositionInString == -1) cout << "Capital 'S' was not found at the beginning of the line" << endl; else cout << "Capital 'S' was found at the beginning of the line" << endl; cout << "Please type 'some_text'" << endl; cin >> TrivialTextString; PositionInString = TrivialExpression.find(TrivialTextString, &StringLength); if (PositionInString == -1) cout << "Capital 'S' was not found at the beginning of the line"; else cout << "Capital 'S' was found at the beginning of the line"; return true; }