CSCE 121 Chapter 23

From Notes
Jump to navigation Jump to search

« previous | Wednesday, December 1, 2010 | next »


Text Manipulation

Example: Email Log where emails are stored in a BIG file.

Find all messages from "John Doe" and print out their subjects

Read entire mail file into a "Mail_file" data structure

  • vector<string> holds lines of mail file, one line per entry
  • vector<Message> indicates sequence of messages; each represented by a pointer to first line of message and pointer to last line

Pseudocode for solution:

foreach (message in Mail_file) {
  sender = find_sender(message);
  multimap[sender] = message
  multimap.equal_range("John Doe").find_subject();
}


Regular Expressions

Cheat Sheet

Find Subject In C++:

Subject: (FW:|RE:)?(.*)