1 / 10

C++

C++. Strings, Regular Expressions, and I/O Streaming

jacie
Download Presentation

C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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.

  2. 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().

  3. C++ • Substrings and Concatenation • Substr() function • ‘+’ used for concatenation • Numeric Conversions • stoi • stol, stoll, stoul, and stoull • stof • stold • to_string and to_wstring

  4. C++ • Regular Expressions • Regex Match and Search Interface • #include <regex> • Similar to declaring a string: regex r1(“<pattern>”) • Grammar based upon the ECMAScript grammar.

  5. C++ Pattern Matching

  6. C++

  7. C++ Assertions and Alternatives

  8. C++

  9. C++

  10. C++ • Regex Operations • Signature Operations • regex_match( … ) • regex_search( … ) • regex_replace( … )

More Related