Download presentation
Presentation is loading. Please wait.
1
CSE 1020:Software Development
Mark Shtern
2
Summary Error handling String Handling
The masquerade and the + operation Applications Character Frequency Character Substitution Fixed-Size codes Variable-Size code StringBuffer
3
Exercise 6.15 Write a program that reads a string and outputs its length exclusive of any trailing asterisks For example, if the user entered “java**” the output should be 4 If the user entered “**” the output should be 0
4
Exercise 6.18 Write a program that reads a string and corrects one aspect of its spelling as follows: The letter pair “ei” is replaced by “ie” unless it is preceded by c For example, “BELEIVE, seive, conceive” becomes “BELIEVE, sieve, conceive”
5
Regular Expression
6
Pattern Matching Pattern matching problems:
Determine whether a given string is made up of two words Determine whether a given string contains an integer surrounded by letters and separated from them by whitespace
7
Regular expression It is a string that describes a pattern in a formal fashion Pattern example: "((0[0-9])||(1[0-2])):[0-5][0-9] [ap]m “ time
8
Character Specification
Range [a-m] Union [a-m[A-M]] Set [abc] Negation [^abc] Intersection [a-m&&[^ck]]
9
Predefined specification
Any character . A digit \d A whitespace character \s A word character \w A punctuation character \p
10
Quantifiers x, once or not at all x, zero or more times
x, one or more times x+ x, at least n but not than m times x{n,m}
11
String class Methods matches replaceAll split
12
Command-Line Arguments
Application launches as following java <class name> <arg1> <arg2> <arg3> Access to command line arguments arg[0] arg1 arg[1] arg2 arg[2] arg3
13
Exercise 6.22 Write a program that reads a DNA sequence from the user and determines whether it is valid To be valid it must: Contain only the letters A C G T Start with ATG Have a character count that is a multiple of 3
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.