String Processing 1 MIS 3406 Department of MIS Fox School of Business

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
Advertisements

Java Programming Strings Chapter 7.
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 2 Getting Started with Java Structure of.
Lesson 3 – Regular Expressions Sandeepa Harshanganie Kannangara MBCS | B.Sc. (special) in MIT.
Chapter 9 Creating Formulas that Manipulate Text Microsoft Office Excel 2003.
Tutorial 14 Working with Forms and Regular Expressions.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
ASP.NET Programming with C# and SQL Server First Edition Chapter 5 Manipulating Strings with C#
Strings The Basics. Strings can refer to a string variable as one variable or as many different components (characters) string values are delimited by.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Screen Scraping Application Introducing String Processing.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
When you read a sentence, your mind breaks it into tokens—individual words and punctuation marks that convey meaning. Compilers also perform tokenization.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 8: Fun with strings.
More about Strings. String Formatting  So far we have used comma separators to print messages  This is fine until our messages become quite complex:
Chapter 3: Classes and Objects Java Programming FROM THE BEGINNING Copyright © 2000 W. W. Norton & Company. All rights reserved Java’s String Class.
More Strings CS303E: Elements of Computers and Programming.
CSC Programming I Lecture 9 September 11, 2002.
Validation final steps Stopping gaps being entered in an input.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming strings.
1 Predefined Classes and Objects Chapter 3. 2 Objectives You will be able to:  Use predefined classes available in the Java System Library in your own.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
Computer Programming 2 Lab (1) I.Fatimah Alzahrani.
Last of String Manipulation. Programming Challenge: Usernames Let’s say you work at the IT department for NYU and you are asked to generate student ID’s.
Strings Characters and Sentences 1.Overview 2.Creating Strings 3.Slicing Strings 4.Searching for substrings 1.
02/03/ Strings Left, Right and Trim. 202/03/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Strings, Characters, and Regular Expressions Session 10 Mata kuliah: M0874 – Programming II Tahun: 2010.
Gator Engineering Google Code Jam 2015 Copyright © 2008 W. W. Norton & Company. All rights reserved. 1.
More String Manipulation. Programming Challenge Define a function that accepts two arguments: a string literal and a single character. Have the function.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
13/06/ Strings Left, Right and Trim. 213/06/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
Lesson 4 String Manipulation. Lesson 4 In many applications you will need to do some kind of manipulation or parsing of strings, whether you are Attempting.
String and Lists Dr. José M. Reyes Álamo.
Sorts, CompareTo Method and Strings
String Manipulation Part 1
Logical Functions Excel Lesson 10.
Excel STDEV.S Function.
String Methods Programming Guides.
CS 330 Class 7 Comments on Exam Programming plan for today:
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
Lecture 19 Strings and Regular Expressions
Strings, Characters and Regular Expressions
Strings, Characters and Regular Expressions
Containers and Lists CIS 40 – Introduction to Programming in Python
Open AvgLoop. It should provide SOME guidance for today’s assignment, but don’t just copy-paste….THINK.
Strings Part 1 Taken from notes by Dr. Neil Moore
Primitive Types Vs. Reference Types, Strings, Enumerations
Modern Programming Tools And Techniques-I Lecture 11: String Handling
CS 106A, Lecture 9 Problem-Solving with Strings
String Manipulation Part 2
Goals Understand how to create and compare Strings.
Manipulating Text In today’s lesson we will look at:
Tonga Institute of Higher Education
String and Lists Dr. José M. Reyes Álamo.
Coding Concepts (Data- Types)
CHAPTER 3: String And Numeric Data In Python
Topics Basic String Operations String Slicing
String Processing 1 MIS 3406 Department of MIS Fox School of Business
Introduction to Computer Science
Python Strings.
Topics Basic String Operations String Slicing
Exam Prep.
Strings Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Topics Basic String Operations String Slicing
What We Want To Do User enters: Mary Smith
Presentation transcript:

String Processing 1 MIS 3406 Department of MIS Fox School of Business Temple University

String Object

Concatenation

Concatenation

Accessing Individual Characters

Accessing Individual Characters

Making Substrings out of Strings – The slice Method The slice method allows you to specify the start and end positions of the part of the string that you want to extract.

Making Substrings out of Strings – The slice Method The start and end position values do not have to be positive. If you specify a negative value for the end position, the end position for your string is what is left when you count backwards from the end.

Making Substrings out of Strings – The slice Method If you specify a negative start position, your start position is the count of whatever you specify starting from the end of the string.

Making Substrings out of Strings – The substr Method The first argument is a number that specifies your starting position, and the second argument is a number that specifies the length of your substring.

Making Substrings out of Strings – The substr Method The first argument is a number that specifies your starting position, and the second argument is a number that specifies the length of your substring.

Making Substrings out of Strings – The substr Method If you don’t specify the length, the substring that gets returned is the string that goes from the start position to the end

Splitting a String – The split Method Calling the split method on a string returns an array of substrings. These substrings are separated by a character or Regular Expression (aka RegEx) that you use to determine when to split apart your string.

Splitting a String – The split Method

Finding Something Inside a String – The indexOf Method The indexOf method takes the character(s) you are looking for as its argument. If what you are looking for is found, it returns the index position in the string where the first occurrence...occurs. If no matches are found, this method gifts you with a -1.

Finding Something Inside a String – The indexOf Method The indexOf method takes the character(s) you are looking for as its argument. If what you are looking for is found, it returns the index position in the string where the first occurrence...occurs. If no matches are found, this method gifts you with a -1.

Finding Something Inside a String – The indexOf Method

Finding Something Inside a String – The indexOf Method In addition to providing the characters to search for, you can also specify an index position on your string to start your search from

Finding Something Inside a String – The lastIndexOf Method

Upper and Lower Casing Strings

Initials.js Write a program that gets a string containing a person’s first, middle, and last names, and displays their first, middle, and last initials. For example, if the user enters John William Smith, the program should display J. W. S.

SumOfDigits.js Write a program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4.

DateConverter.js Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018.

MorseCodeConverter.js Morse code is a code where each letter of the English alphabet, each digit, and various punctuation characters are represented by a series of dots and dashes. See the following table for the mapping of characters to dots and dashes. Write a program that asks the user to enter a string, then converts that string to Morse code.

AlphabeticTelephoneNumberTranslator.js Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion: A, B, and C = 2 D, E, and F = 3 G, H, and I = 4 J, K, and L = 5 M, N, and O = 6 P, Q, R, and S = 7 T, U, and V = 8 W, X, Y, and Z = 9 Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD, the application should display 555-438-3663.

SentenceCapitalizer.js Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.

VowelsAndConsonants.js Write a program with a function that accepts a string as an argument and returns the number of vowels that the string contains. The application should have another function that accepts a string as an argument and returns the number of consonants that the string contains. The application should let the user enter a string, and should display the number of vowels and the number of consonants it contains.

MostFrequentCharacter.js Write a program that lets the user enter a string and displays the character that appears most frequently in the string.

WordSeparator.js Write a program that accepts as input a sentence in which all of the words are run together, but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by spaces, and only the first word starts with an uppercase letter. For example the string “StopAndSmellTheRoses.” would be converted to “Stop and smell the roses.”

PigLatin.js Write a program that accepts a sentence as input and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then, you append the string “ay” to the word. Here is an example: