Chapter 12: Text Processing

Slides:



Advertisements
Similar presentations
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Advertisements

Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Constants and Data Types Constants Data Types Reading for this class: L&L,
Programming Character I/O. COMP102 Prog. Fundamentals I: Character I/O/ Slide 2 More on char Type l Constant Declaration: const char star = '*'; l Variable.
An Introduction to Programming with C++ Fifth Edition Chapter 5 The Selection Structure.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
1 Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class:
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
CIS Computer Programming Logic
STRINGS CMSC 201 – Lab 3. Overview Objectives for today's lab:  Obtain experience using strings in Python, including looping over characters in strings.
Strings CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
CPS120: Introduction to Computer Science
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 7 Files.
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
Introduction to Matlab Module #4 Page 1 Introduction to Matlab Module #4 – Programming Topics 1.Programming Basics (fprintf, standard input) 2.Relational.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
A FIRST BOOK OF C++ CHAPTER 14 THE STRING CLASS AND EXCEPTION HANDLING.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
8 1 String Manipulation CGI/Perl Programming By Diane Zak.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
LECTURE 5 Strings. STRINGS We’ve already introduced the string data type a few lectures ago. Strings are subtypes of the sequence data type. Strings are.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
Strings in Python String Methods. String methods You do not have to include the string library to use these! Since strings are objects, you use the dot.
C LANGUAGE UNIT 3. UNIT 3 Arrays Arrays – The concept of array – Defining arrays – Initializing arrays.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Chapter 9: Sorting and Searching Arrays
Chapter 6 JavaScript: Introduction to Scripting
Chapter 2: Introduction to C++
Perl-Compatible Regular Expressions Part 1
CS31 Discussion 1E Jie(Jay) Wang Week5 Oct.27.
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
Multiple variables can be created in one declaration
The Selection Structure
Introduction to Scripting
Chapter 5: Repetition Structures
Agenda Warmup Lesson 2.5 (Ascii, Method Overloading)
Chapter 2: Introduction to C++
An Introduction to Programming with C++ Fifth Edition
Chapter 5 Structures.
Arrays, For loop While loop Do while loop
Chapter 12: Text Processing
Chapter 7: Strings and Characters
MSIS 655 Advanced Business Applications Programming
Basic Python Collective variables (sequences) Lists (arrays)
Chapter 7 Files and Exceptions
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
10.1 Character Testing.
String and Lists Dr. José M. Reyes Álamo.
LabVIEW.
Starting Out with Programming Logic & Design
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 2: Introduction to C++.
Chapter 7: Input Validation
Programming Logic and Design Fifth Edition, Comprehensive
The Data Element.
An Introduction to Programming with C++ Fifth Edition
Introduction to Computer Science
The Data Element.
Programming Basics Review
STRING MANUPILATION.
Presentation transcript:

Chapter 12: Text Processing Starting Out with Programming Logic & Design Second Edition by Tony Gaddis

Chapter Topics 12.1 Introduction 12.2 Character-by-Character Text Processing

12.1 Introduction Table 12-1 (see page 460) lists the common string functions covered so far. These functions operate on strings. Sometimes, however, you need to operate on the individual characters in a string.

12.2 Character-by-Character Text Processing Most languages provide a way to access the individual characters in a string. Often this is done with subscript notation, similar to accessing the elements of an array. Pseudocode example: Declare String greeting = "Hello world" Display greeting[0] Displays the first character in the string.

12.2 Character-by-Character Text Processing Subscript 0 accesses the first character, subscript 1 accesses the second character, and so on…

12.2 Character-by-Character Text Processing A loop can be used to step through all of the characters in a string.

12.2 Character-by-Character Text Processing This technique also allows characters to modified: Declare String str = "Coffee" str[0] = "T" Display str Changes the first character to "T" Displays "Toffee"

12.2 Character-by-Character Text Processing Table 12-2 Common Character Testing Functions Function Description isDigit(character) Returns True if character is a numeric digit, or False otherwise. isLetter(character) Returns True if character is an alphabetic letter or False otherwise. isLower(character) Returns True if character is a lowercase letter or False otherwise. isUpper(character) Returns True if character is an uppercase letter or False otherwise. isWhiteSpace (character) Returns True if character is a whitespace character or False otherwise. (A whitespace character is a space, a tab, or a newline.)

12.2 Character-by-Character Text Processing Example from Program 12-4 (see page 464) to count the number of uppercase characters in a string. str is a String variable that contains a valid string.

12.2 Character-by-Character Text Processing Table 12-3 String Insertion and Deletion Modules Function Description insert(string1, position, string2) string1 is a String, position is an Integer, and string2 is a String. The function inserts string2 into string1, beginning at position. delete(string, start, end) string is a String, start is an Integer, and end is an Integer. The function deletes from string all of the characters beginning at the position specified by start, and ending at the position specified by end. The character at the ending position is included in the deletion.

12.2 Character-by-Character Text Processing Example: Declare String str = "New City" insert(str, 4, "York ") Display str Displays "New York City"

12.2 Character-by-Character Text Processing Example: Declare String str = "I ate 1000 blueberries!" delete(str, 8, 9) Display str Displays "I ate 10 blueberries!"