Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607.

Slides:



Advertisements
Similar presentations
Strings and regular expressions Day 10 LING Computational Linguistics Harry Howard Tulane University.
Advertisements

1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
PERL Part 3 1.Subroutines 2.Pattern matching and regular expressions.
Linux+ Guide to Linux Certification, Second Edition
Scripting Languages Chapter 8 More About Regular Expressions.
CSE467/567 Computational Linguistics Carl Alphonce Computer Science & Engineering University at Buffalo.
Filters using Regular Expressions grep: Searching a Pattern.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Prof. Alfred J Bird, Ph.D., NBCT Office – Wheatly 2nd floor Office Hours – MW 3:00PM to 4:00PM.
More on Regular Expressions Regular Expressions More character classes \s matches any whitespace character (space, tab, newline etc) \w matches.
Prof. Alfred J Bird, Ph.D., NBCT Office – Wheatly 2nd floor Office Hours – MW 3:00PM.
Lecture 7: Perl pattern handling features. Pattern Matching Recall =~ is the pattern matching operator A first simple match example print “An methionine.
System Programming Regular Expressions Regular Expressions
Programming Perl in UNIX Course Number : CIT 370 Week 4 Prof. Daniel Chen.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormack 3rd floor 607.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Perl and Regular Expressions Regular Expressions are available as part of the programming languages Java, JScript, Visual Basic and VBScript, JavaScript,
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students – * Office – Wheatly.
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Prof. Alfred J Bird, Ph.D., NBCT Door Code: * Office – McCormick 3rd floor 607 Office.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
Python Regular Expressions Easy text processing. Regular Expression  A way of identifying certain String patterns  Formally, a RE is:  a letter or.
Prof. Alfred J Bird, Ph.D., NBCT -bird.wikispaces.umb.edu/ Office – McCormick 3rd floor.
Regular Expressions.
Perl: Lecture 1 The language. What Perl is Merger of Unix tools – Very popular under UNIX – shell, sed, awk Programming language – C syntax Scripting.
Overview A regular expression defines a search pattern for strings. Regular expressions can be used to search, edit and manipulate text. The pattern defined.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
©Brooks/Cole, 2001 Chapter 9 Regular Expressions.
CS346 Regular Expressions1 Pattern Matching Regular Expression.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
I/O Redirection & Regular Expressions CS 2204 Class meeting 4 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
2004/12/051/27 SPARCS 04 Seminar Regular Expression By 박강현 (lightspd)
Regular Expressions CS 2204 Class meeting 6 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
CIT 383: Administrative ScriptingSlide #1 CIT 383: Administrative Scripting Regular Expressions.
Regular Expressions Pattern and String Matching in Text.
Karthik Sangaiah.  Developed by Larry Wall ◦ “There’s more than one way to do it” ◦ “Easy things should be easy and hard things should be possible” 
16-Dec-15Advanced Programming Spring 2002 sed and awk Henning Schulzrinne Dept. of Computer Science Columbia University.
Awk- An Advanced Filter by Prof. Shylaja S S Head of the Dept. Dept. of Information Science & Engineering, P.E.S Institute of Technology, Bangalore
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. ADVANCED.
1 Lecture 10 Introduction to AWK COP 3344 Introduction to UNIX.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
IT443 – Network Security Administration Week 2 – Wireshark Instructor: Alfred J Bird, Ph.D., NBCT
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607.
ORAFACT Text Processing. ORAFACT Searching Inside Files grep - searches for patterns within files grep [options] [[-e] pattern] filename [...] -n shows.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3nd floor, room 607 Office Hours –Tuesday.
CS 330 Programming Languages 09 / 30 / 2008 Instructor: Michael Eckmann.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Monday 3:00 to 4:00 and.
Chapter 18 The HTML Tag
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607.
Java Basics Regular Expressions.  A regular expression (RE) is a pattern used to search through text.  It either matches the.
Midterm Review October Closed book one hand written page of notes of your own making October Closed book one hand written page of notes of.
Regular Expressions.
PROGRAMMING THE BASH SHELL PART III by İlker Korkmaz and Kaya Oğuz
Regular Expressions Copyright Doug Maxwell (
CS 330 Class 7 Comments on Exam Programming plan for today:
Regular Expressions ICCM 2017
Looking for Patterns - Finding them with Regular Expressions
IT441 Network Services Administration
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
CSCI 431 Programming Languages Fall 2003
Regular Expressions
Regular Expressions and Grep
Lab 8: Regular Expressions
Presentation transcript:

Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and Thursday 4:00PM to 5:15PM

 Given a text file (i.e. gettysburg.txt in my home directory) write a program to find if a given word is used in the file.  Use the split function as such:  my $word (split)  This will break up the line into words separated by whitespace characters  If the word is found, print out a message indicating such.

 Given a text file (i.e. gettysburg.txt in my home directory) write a program to find if the a given word is used in the file.  Use the split function as such:  my $word (split)  This will break up the line into words separated by whitespace characters  If the word is found, print out a message indicating such.  Go to readAndPrint1.pl in my directory for a solution.

 Get the file now1.txt from my directory  /home/abird  How would you use SED to change the word Now to Then ?  How would you used SED to change the phrase Now is to the phrase Then was ?  Congratulations, you have just used your first Regex!!!

 Often called regex  One of the most useful features of Perl  Available in most programming languages  You used it in BASH  What does this do?  s/abc/ABC/  Welcome to the world of regular expresions

 Given a text file (i.e. gettysburg.txt in my home directory) write a program to find if the a given word is used in the file.  Use a regular expression such as  /and/  If the word is found, print out a message indicating such.

 Given a text file (i.e. gettysburg.txt in my home directory) write a program to find if the a given word is used in the file.  Use a regular expression such as  /and/  If the word is found, print out a message indicating such.  Go to readAndPrint.pl in my directory for a solution.

 What is different between the two methods of searching?  What if I want to ignore the case of the letters?  How would you modify the readAndPrint1.pl program to check without regard to capitalization?  It is not very easy is it!  With regular expressions it is much simpler.  /$word/i

 What if I wanted to find a pattern only at the start of a line or at the end of a line?  In a Regex we can use anchors.  To indicate the pattern must be at the start of a line we use the ^  i.e. /^The/  To indicate the pattern must be at the end of the line we use the anchor $  i.e./end$/

 We can make our Regex more general by using metacharacters.  See the table on page 167 in the text  Four of the more common metacharacters are: .Matches any character except newline  ? Preceding character or group may be present 0 or 1 time  +Preceding character or group is present 1 or more times  *Preceding character or group may be present 0 or more times

 Write a program that:  Reads the file alice.txt in my home directory  Checks to see if any given word is present without regard to capitalization  Modify the program to see if there are any numbers in the file

 Modify the earlier program to accept a file name as input and check for a word entered from the keyboard in the file.

 Read pages 153 to 177 in the textbook.