E N D
C++ • Strings, Regular Expressions, and I/O Streaming • Strings are objects of one of the string classes - string, wstring, u16string or u32string. These classes behave as though they are one of the fundamental data types and offers an extremely rich set of functions making data manipulation very straight-forward. All of the types and functions for strings are contained in the <string> header file. • Regular Expressions is fundamentally pattern matching within strings. It is the use of wildcards and patterns to find or replace string segments. Regular expressions, then, can be used to: • Match some input with the expression • Search some input for the expression • Use some defined token in an expression (e.g. ‘*’) • Modify some input based upon the expression.
C++ • I/O Streaming All software has some sort of I/O. C++ defines a library known as the I/O Stream Library which operates various aspects of I/O. It, like C, represents I/O as streams of data rather than some physical representation. • Strings • String types, in order to be used, must be included in source code with #include <string> : string s1 (“some string”) • Includes wide character strings for internationalization. • Typical functions consist of: assign(), length(), replace(), compare(), clear(), and erase().
C++ • Substrings and Concatenation • Substr() function • ‘+’ used for concatenation • Numeric Conversions • stoi • stol, stoll, stoul, and stoull • stof • stold • to_string and to_wstring
C++ • Regular Expressions • Regex Match and Search Interface • #include <regex> • Similar to declaring a string: regex r1(“<pattern>”) • Grammar based upon the ECMAScript grammar.
C++ Pattern Matching
C++ Assertions and Alternatives
C++ • Regex Operations • Signature Operations • regex_match( … ) • regex_search( … ) • regex_replace( … )