Introduction to regular expressions
|
|
- Mildred Jefferson
- 6 years ago
- Views:
Transcription
1 Introduction to regular expressions Table of Contents Introduction to regular expressions Here's how we do it Iteration 1: skill level > Wollowitz Iteration 2: skill level > Rakesh Introduction to regular expressions What are regular expressions Regular expressions describe a chunk of text with certain properties Why is that useful, and where is it useful? Searching substrings Searching and replacing, scientist style Concise text manipulation programs Find double adresses in adress books and delete one entry Switch first and last names in text manipulate tabulated data manipulate adresses extract biological data from table Here's how we do it 4 iterations, 4 exercises 4 models, from Rutherford to pretty nice Solutions at 4.15 and 5.30 DISCLAIMER: don't take slides from the first iterations as the full truth. They just provide models to help you understand. Iteration 1: skill level > Wollowitz Building blocks Literal text
2 In the most basic case, the regex searches for literal text: pattern = 'ACAC' string = 'TACAGACACGAC' match = re.search(pattern, string) # finds: ACAC Character classes Often, we want to look for a set of characters instead of a single literal character The dot The dot character matches everything except the newline character pattern = r'ac.c' string = 'TACTCACACGAC' # Finds: ACTC Standard sets Standard sets describe categories of characters \w alphanumeric chars and underscore a z and A Z and _ \d decimal numbers 0 9 \s whitespace \t\n etc. Complements to the standard sets \W, \D and \ S mean everything except \w, \d or \s respectively pattern = r'\w\w' string = 'Hello World' # finds: 'o ' Character ranges Instead of the standard sets, you may use custom sets by including these elements in brackets []: 1. Literal characters: [abc] 2. Standard set: [\w\d] 3. Ranges [a e]
3 4. Complement [^\w] beginning_of_headline = r'[a-e]) ' headline1 = 'A) Regexes are useful' headline2 = 'F) Regexes are fun' Searching with re.search re.search(pattern, string) starts looking for pattern at the beginning of string goes through all positions in the string, until a match is found re.search returns a match object if a match was found None otherwise We will talk more about the match object later. Key point for now: it is truthy The regex engine, 1/10 Text based and regex based engines There are two different algorithmic approaches to deal with regular expression searches: 1. Text based engine (DFA) 2. Regex based engine (NFA) Here, we are only concerned with regex based engines. These engines are used in Java, Perl, Python, R etc., so this is likely what you will encounter most of the time. The regex engine is eager To find its match, the regex engine follows this basic algorithm: 1. Start at position 0 (beginning of the string) 2. Try every possible way to match the pattern from this position 3. As soon as a complete match is found: end the search and return the match 4. If no match was found: go to the next position and repeat from step 2 Incredibly important implications 1/10 1. One of the leftmost matches wins Quantifiers
4 Quantifiers specify how often a regex token may appear m times To specify that a token has to appear mtimes: pattern = r'.{3}b' Between m and n times To specify that a token may appear between mand ntimes: pattern = r'.{3,5}b' Shortcuts {,} * {1,} + {0,1}? The regex engine, 2/10 By default regex engine is greedy The default modifiers are greedy. They try to match as much of the text as possible. pattern = r'.*cat' string = 'my cat is a really fat cat' # matches: 'my cat is a really fat cat' The regex engine uses backtracking to try out all possible ways to match a pattern This was explained on the blackboard. Here the main points for your reference: the regex engine keeps track of two positions the current token in the regex the current position in the string the engine works through all tokens of the regex step by step the position in the string is updated as required by matching of the tokens whenever the regex engine can do more than one thing, it will keep track of its decisions
5 if a later token in the regex can't be matched on the current matching 'path', the engine goes back to the last branching point in the path and takes an alternative decision this algorithm is followed until the first match is found: the engine stops as soon as a successful match is found, independent of whether more and perhaps longer matches could be found by continuing the search all possible ways to match a regex have been tried without success: no match is found Iteration 2: skill level > Rakesh Alternatives To allow the engine to select between alternatives, combine them with pattern = r'(howard Rakesh Sheldon Leonard) was here' string = 'Rakesh was here' The regex engine, 3/10 Alternatives are tried from left to right Implications: 1. The first viable alternative is taken 2. The alternatives operator is not greedy Incredibly important consequences of the algorithm 1. One of the leftmost matches wins 2. The first viable alternative is taken, even if a longer alternative would also match Substitution re.sub(pattern, replacement, string) More building blocks Capturing groups Standard capturing groups
6 To capture and reuse parts of a match, put the regex tokens in parentheses get_day_from_date = '\w+ (\d+)' date = 'May 15' # 15 is captured Anchors ^ beginning of the string $ end of the string \b \w to \W boundary or \w to 'void' boundary Reusing captured content In the same pattern \N get_double_day_error = '\w+ (\d\d)\1' date = 'May 15' # nothing matched, this one is ok date = 'May 1515' # date is matched, this one is not ok In substitutions \N string = 'The protein BNIP3... BNIP-3.. bnip three...' pattern = r'bnip?-?(3 three)' replacement = r'bnup \1' Through the match objects Return the content of all captured groups m.groups() m.group(0) m.group(1,2)
7 If you want to learn more Author: Stephen Kraemer Created: Mi 07:50 Validate
Dr. Sarah Abraham University of Texas at Austin Computer Science Department. Regular Expressions. Elements of Graphics CS324e Spring 2017
Dr. Sarah Abraham University of Texas at Austin Computer Science Department Regular Expressions Elements of Graphics CS324e Spring 2017 What are Regular Expressions? Describe a set of strings based on
More informationPerl Regular Expressions. Perl Patterns. Character Class Shortcuts. Examples of Perl Patterns
Perl Regular Expressions Unlike most programming languages, Perl has builtin support for matching strings using regular expressions called patterns, which are similar to the regular expressions used in
More informationRegular Expressions. Upsorn Praphamontripong. CS 1111 Introduction to Programming Spring [Ref: https://docs.python.org/3/library/re.
Regular Expressions Upsorn Praphamontripong CS 1111 Introduction to Programming Spring 2018 [Ref: https://docs.python.org/3/library/re.html] Overview: Regular Expressions What are regular expressions?
More informationBioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)
Bioinformatics Programming EE, NCKU Tien-Hao Chang (Darby Chang) 1 Regular Expression 2 http://rp1.monday.vip.tw1.yahoo.net/res/gdsale/st_pic/0469/st-469571-1.jpg 3 Text patterns and matches A regular
More informationLecture 2. Regular Expression Parsing Awk
Lecture 2 Regular Expression Parsing Awk Shell Quoting Shell Globing: file* and file? ls file\* (the backslash key escapes wildcards) Shell Special Characters ~ Home directory ` backtick (command substitution)
More informationRegular Expressions. Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland
Regular Expressions Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland November 11 th, 2015 Regular expressions provide a flexible way
More informationCS 301. Lecture 05 Applications of Regular Languages. Stephen Checkoway. January 31, 2018
CS 301 Lecture 05 Applications of Regular Languages Stephen Checkoway January 31, 2018 1 / 17 Characterizing regular languages The following four statements about the language A are equivalent The language
More informationRegular Expressions. Steve Renals (based on original notes by Ewan Klein) ICL 12 October Outline Overview of REs REs in Python
Regular Expressions Steve Renals s.renals@ed.ac.uk (based on original notes by Ewan Klein) ICL 12 October 2005 Introduction Formal Background to REs Extensions of Basic REs Overview Goals: a basic idea
More informationhttps://lambda.mines.edu You should have researched one of these topics on the LGA: Reference Couting Smart Pointers Valgrind Explain to your group! Regular expression languages describe a search pattern
More informationLING115 Lecture Note Session #7: Regular Expressions
LING115 Lecture Note Session #7: Regular Expressions 1. Introduction We need to refer to a set of strings for various reasons: to ignore case-distinction, to refer to a set of files that share a common
More informationThis page covers the very basics of understanding, creating and using regular expressions ('regexes') in Perl.
NAME DESCRIPTION perlrequick - Perl regular expressions quick start Perl version 5.16.2 documentation - perlrequick This page covers the very basics of understanding, creating and using regular expressions
More informationCSE : Python Programming
CSE 399-004: Python Programming Lecture 11: Regular expressions April 2, 2007 http://www.seas.upenn.edu/~cse39904/ Announcements About those meeting from last week If I said I was going to look into something
More informationRegular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)
Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in
More informationLearning Ruby. Regular Expressions. Get at practice page by logging on to csilm.usu.edu and selecting. PROGRAMMING LANGUAGES Regular Expressions
Learning Ruby Regular Expressions Get at practice page by logging on to csilm.usu.edu and selecting PROGRAMMING LANGUAGES Regular Expressions Regular Expressions A regular expression is a special sequence
More informationRegex Guide. Complete Revolution In programming For Text Detection
Regex Guide Complete Revolution In programming For Text Detection What is Regular Expression In computing, a regular expressionis a specific pattern that provides concise and flexible means to "match"
More informationCSCI 4152/6509 Natural Language Processing Lecture 6: Regular Expressions; Text Processing in Perl
Lecture 6 p.1 Faculty of Computer Science, Dalhousie University CSCI 4152/6509 Natural Language Processing Lecture 6: Regular Expressions; Text Processing in Perl 18-Jan-2019 Location: LSC Psychology P5260
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Today's learning goals Sipser Ch 1.2, 1.3 Decide whether or not a string is described by a given regular expression
More informationCompiler Design. 2. Regular Expressions & Finite State Automata (FSA) Kanat Bolazar January 21, 2010
Compiler Design. Regular Expressions & Finite State Automata (FSA) Kanat Bolazar January 1, 010 Contents In these slides we will see 1.Introduction, Concepts and Notations.Regular Expressions, Regular
More informationTable ofcontents. Preface. 1: Introduction to Regular Expressions xv
Preface... xv 1: Introduction to Regular Expressions... 1 Solving Real Problems.. 2 Regular Expressions as a Language.. 4 The Filename Analogy.. 4 The Language Analogy 5 The Regular-Expression Frame of
More informationCSC207 Week 9. Larry Zhang
CSC207 Week 9 Larry Zhang 1 Logistics A2 Part 2 is out. A1 Part 2 marks out on Peer Assessment, for remarking requests, contact Larry. 2 Today s outline File I/O Regular Expressions 3 File I/O: read and
More informationSlide 1 Side Effects Duration: 00:00:53 Advance mode: Auto
Side Effects The 5 numeric operators don't modify their operands Consider this example: int sum = num1 + num2; num1 and num2 are unchanged after this The variable sum is changed This change is called a
More informationDATA STRUCTURE AND ALGORITHM USING PYTHON
DATA STRUCTURE AND ALGORITHM USING PYTHON Sorting, Searching Algorithm and Regular Expression Peter Lo Sorting Algorithms Put Elements of List in Certain Order 2 Bubble Sort The bubble sort makes multiple
More informationRegular Expressions. Perl PCRE POSIX.NET Python Java
ModSecurity rules rely heavily on regular expressions to allow you to specify when a rule should or shouldn't match. This appendix teaches you the basics of regular expressions so that you can better make
More informationFundamentals of Programming. November 19, 2017
15-112 Fundamentals of Programming November 19, 2017 Today Regular Expressions Read pages 171-172 and 127-129 Background We have done several exercises where we were looking for specific patterns in a
More informationEffective Programming Practices for Economists. 17. Regular Expressions
Effective Programming Practices for Economists 17. Regular Expressions Hans-Martin von Gaudecker Department of Economics, Universität Bonn Motivation Replace all occurences of my name in the project template
More informationRegular Expressions. Regular Expression Syntax in Python. Achtung!
1 Regular Expressions Lab Objective: Cleaning and formatting data are fundamental problems in data science. Regular expressions are an important tool for working with text carefully and eciently, and are
More informationRegular Expressions.
Regular Expressions http://xkcd.com/208/ Overview Regular expressions are essentially a tiny, highly specialized programming language (embedded inside Python and other languages) Can use this little language
More informationLexical Analysis. Lecture 3-4
Lexical Analysis Lecture 3-4 Notes by G. Necula, with additions by P. Hilfinger Prof. Hilfinger CS 164 Lecture 3-4 1 Administrivia I suggest you start looking at Python (see link on class home page). Please
More informationComputer Systems and Architecture
Computer Systems and Architecture Stephen Pauwels Regular Expressions Academic Year 2018-2019 Outline What is a Regular Expression? Tools Anchors, Character sets and Modifiers Advanced Regular Expressions
More informationRegExpr:Review & Wrapup; Lecture 13b Larry Ruzzo
RegExpr:Review & Wrapup; Lecture 13b Larry Ruzzo Outline More regular expressions & pattern matching: groups substitute greed RegExpr Syntax They re strings Most punctuation is special; needs to be escaped
More informationapplied regex implementing REs using finite state automata using REs to find patterns Informatics 1 School of Informatics, University of Edinburgh 1
applied regex cl implementing REs using finite state automata using REs to find patterns Informatics 1 School of Informatics, University of Edinburgh 1 Is there a regular expression for every FSM? a 1
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationCoding Workshop. Learning to Program with an Arduino. Lecture Notes. Programming Introduction Values Assignment Arithmetic.
Coding Workshop Learning to Program with an Arduino Lecture Notes Table of Contents Programming ntroduction Values Assignment Arithmetic Control Tests f Blocks For Blocks Functions Arduino Main Functions
More informationBeginning Perl for Bioinformatics. Steven Nevers Bioinformatics Research Group Brigham Young University
Beginning Perl for Bioinformatics Steven Nevers Bioinformatics Research Group Brigham Young University Why Use Perl? Interpreted language (quick to program) Easy to learn compared to most languages Designed
More informationMore Details about Regular Expressions
More Details about Regular Expressions Basic Regular Expression Notation Summary of basic notations to match single characters and sequences of characters 1. /[abc]/ = /a b c/ Character class; disjunction
More informationLanguage Reference Manual
ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents
More informationChapter Eight: Regular Expression Applications. Formal Language, chapter 8, slide 1
Chapter Eight: Regular Expression Applications Formal Language, chapter 8, slide 1 1 We have seen some of the implementation techniques related to DFAs and NFAs. These important techniques are like tricks
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More information正则表达式 Frank from https://regex101.com/
符号 英文说明 中文说明 \n Matches a newline character 新行 \r Matches a carriage return character 回车 \t Matches a tab character Tab 键 \0 Matches a null character Matches either an a, b or c character [abc] [^abc]
More informationHaskell: Lists. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, February 24, Glenn G.
Haskell: Lists CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, February 24, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks
More informationCIS192 Python Programming
CIS192 Python Programming Regular Expressions and Other Modules Raymond Yin University of Pennsylvania October 5, 2016 Raymond Yin (University of Pennsylvania) CIS 192 October 5, 2016 1 / 49 Outline 1
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Today's learning goals Sipser Ch 1.2, 1.3 Design NFA recognizing a given language Convert an NFA (with or without
More informationPythonic Coding Style. C-START Python PD Workshop
A Foolish Consistency is the Hobgoblin of Little Minds Guido van Rossum (creator of Python) makes a point: code is read more often than it is written, so readability counts. A Foolish Consistency is the
More informationCS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)
CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going
More informationPrinciples of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore
(Refer Slide Time: 00:20) Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 4 Lexical Analysis-Part-3 Welcome
More informationIntroduction to Regular Expressions Version 1.3. Tom Sgouros
Introduction to Regular Expressions Version 1.3 Tom Sgouros June 29, 2001 2 Contents 1 Beginning Regular Expresions 5 1.1 The Simple Version........................ 6 1.2 Difficult Characters........................
More informationLECTURE 8. The Standard Library Part 2: re, copy, and itertools
LECTURE 8 The Standard Library Part 2: re, copy, and itertools THE STANDARD LIBRARY: RE The Python standard library contains extensive support for regular expressions. Regular expressions, often abbreviated
More informationIntroduction; Parsing LL Grammars
Introduction; Parsing LL Grammars CS 440: Programming Languages and Translators Due Fri Feb 2, 11:59 pm 1/29 pp.1, 2; 2/7 all updates incorporated, solved Instructions You can work together in groups of
More informationCS 11 Haskell track: lecture 1
CS 11 Haskell track: lecture 1 This week: Introduction/motivation/pep talk Basics of Haskell Prerequisite Knowledge of basic functional programming e.g. Scheme, Ocaml, Erlang CS 1, CS 4 "permission of
More informationObject-Oriented Software Engineering CS288
Object-Oriented Software Engineering CS288 1 Regular Expressions Contents Material for this lecture is based on the Java tutorial from Sun Microsystems: http://java.sun.com/docs/books/tutorial/essential/regex/index.html
More informationRegular Expressions for Technical Writers (tutorial)
Regular Expressions for Technical Writers (tutorial) tcworld conference 2016 - Stuttgart, Germany Scott Prentice, Leximation, Inc. modified 2017-05-13 (fixed typos) Introduction Scott Prentice, President
More informationRegular Expressions. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 9
Regular Expressions Computer Science and Engineering College of Engineering The Ohio State University Lecture 9 Language Definition: a set of strings Examples Activity: For each above, find (the cardinality
More informationCS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG) Objectives Introduce Pushdown Automaton (PDA) Show that PDA = CFG In terms of descriptive power Pushdown Automaton (PDA) Roughly
More informationCS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code
CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output
More informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write
More informationSTATS Data analysis using Python. Lecture 0: Introduction and Administrivia
STATS 700-002 Data analysis using Python Lecture 0: Introduction and Administrivia Data science has completely changed our world Course goals Survey popular tools in academia/industry for data analysis
More informationRegular Expressions in programming. CSE 307 Principles of Programming Languages Stony Brook University
Regular Expressions in programming CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 What are Regular Expressions? Formal language representing a
More informationCS 2112 Lab: Regular Expressions
October 10, 2012 Regex Overview Regular Expressions, also known as regex or regexps are a common scheme for pattern matching regex supports matching individual characters as well as categories and ranges
More informationCS 177 Recitation. Week 1 Intro to Java
CS 177 Recitation Week 1 Intro to Java Questions? Computers Computers can do really complex stuff. How? By manipulating data according to lists of instructions. Fundamentally, this is all that a computer
More informationAlgorithmic Approaches for Biological Data, Lecture #8
Algorithmic Approaches for Biological Data, Lecture #8 Katherine St. John City University of New York American Museum of Natural History 17 February 2016 Outline More on Pattern Finding: Regular Expressions
More informationGetting Started Values, Expressions, and Statements CS GMU
Getting Started Values, Expressions, and Statements CS 112 @ GMU Topics where does code go? values and expressions variables and assignment 2 where does code go? we can use the interactive Python interpreter
More informationSTATS Data Analysis using Python. Lecture 15: Advanced Command Line
STATS 700-002 Data Analysis using Python Lecture 15: Advanced Command Line Why UNIX/Linux? As a data scientist, you will spend most of your time dealing with data Data sets never arrive ready to analyze
More informationMITOCW watch?v=se4p7ivcune
MITOCW watch?v=se4p7ivcune The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationDaMPL. Language Reference Manual. Henrique Grando
DaMPL Language Reference Manual Bernardo Abreu Felipe Rocha Henrique Grando Hugo Sousa bd2440 flt2107 hp2409 ha2398 Contents 1. Getting Started... 4 2. Syntax Notations... 4 3. Lexical Conventions... 4
More informationCMSC 330: Organization of Programming Languages. Ruby Regular Expressions
CMSC 330: Organization of Programming Languages Ruby Regular Expressions 1 String Processing in Ruby Earlier, we motivated scripting languages using a popular application of them: string processing The
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationRegular Expressions for Technical Writers
Regular Expressions for Technical Writers STC Summit 2017 - Washington DC Scott Prentice, Leximation, Inc. Introduction Scott Prentice, President of Leximation, Inc. Specializing in FrameMaker plugin development
More informationWhat we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements
Topic 4 Variables Once a programmer has understood the use of variables, he has understood the essence of programming -Edsger Dijkstra What we will do today Explain and look at examples of primitive data
More informationVariables, Functions and String Formatting
Variables, Functions and String Formatting Code Examples HW 2-1, 2-2 Logical Expressions Comparison Operators a == b Comparison operators compare the right-hand side and the lefthand side and return True
More informationStructure of Programming Languages Lecture 3
Structure of Programming Languages Lecture 3 CSCI 6636 4536 Spring 2017 CSCI 6636 4536 Lecture 3... 1/25 Spring 2017 1 / 25 Outline 1 Finite Languages Deterministic Finite State Machines Lexical Analysis
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments Reading Assignment: Chapter 3: Introduction to Parameters and Objects The Class 10 Exercise
More informationLexical Analysis. Finite Automata
#1 Lexical Analysis Finite Automata Cool Demo? (Part 1 of 2) #2 Cunning Plan Informal Sketch of Lexical Analysis LA identifies tokens from input string lexer : (char list) (token list) Issues in Lexical
More informationPowerGREP. Manual. Version October 2005
PowerGREP Manual Version 3.2 3 October 2005 Copyright 2002 2005 Jan Goyvaerts. All rights reserved. PowerGREP and JGsoft Just Great Software are trademarks of Jan Goyvaerts i Table of Contents How to
More informationLexical Analysis. Chapter 2
Lexical Analysis Chapter 2 1 Outline Informal sketch of lexical analysis Identifies tokens in input string Issues in lexical analysis Lookahead Ambiguities Specifying lexers Regular expressions Examples
More informationML 4 A Lexer for OCaml s Type System
ML 4 A Lexer for OCaml s Type System CS 421 Fall 2017 Revision 1.0 Assigned October 26, 2017 Due November 2, 2017 Extension November 4, 2017 1 Change Log 1.0 Initial Release. 2 Overview To complete this
More informationIntroduction to Unix
Introduction to Unix Part 1: Navigating directories First we download the directory called "Fisher" from Carmen. This directory contains a sample from the Fisher corpus. The Fisher corpus is a collection
More informationLecture 15 (05/08, 05/10): Text Mining. Decision, Operations & Information Technologies Robert H. Smith School of Business Spring, 2017
Lecture 15 (05/08, 05/10): Text Mining Decision, Operations & Information Technologies Robert H. Smith School of Business Spring, 2017 K. Zhang BMGT 404 Practical examples Matching a password 6 to 12 characters
More information=~ determines to which variable the regex is applied. In its absence, $_ is used.
NAME DESCRIPTION OPERATORS perlreref - Perl Regular Expressions Reference This is a quick reference to Perl's regular expressions. For full information see perlre and perlop, as well as the SEE ALSO section
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationYork University Department of Electrical Engineering and Computer Science. Regular Expressions
Regular Expressions 26 The matches Method From the API for the matches method in the String class 27 1 What is the Output? String s1 = "a"; String s2 = "b"; String regex = "a"; output.println(s1.matches(regex)
More informationJava+- Language Reference Manual
Fall 2016 COMS4115 Programming Languages & Translators Java+- Language Reference Manual Authors Ashley Daguanno (ad3079) - Manager Anna Wen (aw2802) - Tester Tin Nilar Hlaing (th2520) - Systems Architect
More informationRegular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP
Regular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP address as a string and do a search. But, what if you didn
More informationPython for Analytics. Python Fundamentals RSI Chapters 1 and 2
Python for Analytics Python Fundamentals RSI Chapters 1 and 2 Learning Objectives Theory: You should be able to explain... General programming terms like source code, interpreter, compiler, object code,
More informationRegex, Sed, Awk. Arindam Fadikar. December 12, 2017
Regex, Sed, Awk Arindam Fadikar December 12, 2017 Why Regex Lots of text data. twitter data (social network data) government records web scrapping many more... Regex Regular Expressions or regex or regexp
More informationRegular Expressions!!
Regular Expressions!! In your mat219_class project 1. Copy code from D2L to download regex-prac9ce.r, and run in the Console. 2. Open a blank R script and name it regex-notes. library(tidyverse) regular
More informationLecture Outline. COMP-421 Compiler Design. What is Lex? Lex Specification. ! Lexical Analyzer Lex. ! Lex Examples. Presented by Dr Ioanna Dionysiou
Lecture Outline COMP-421 Compiler Design! Lexical Analyzer Lex! Lex Examples Presented by Dr Ioanna Dionysiou Figures and part of the lecture notes taken from A compact guide to lex&yacc, epaperpress.com
More informationFirst Java Program - Output to the Screen
First Java Program - Output to the Screen These notes are written assuming that the reader has never programmed in Java, but has programmed in another language in the past. In any language, one of the
More informationRegular expressions. LING78100: Methods in Computational Linguistics I
Regular expressions LING78100: Methods in Computational Linguistics I String methods Python strings have methods that allow us to determine whether a string: Contains another string; e.g., assert "and"
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More informationA PROGRAM IS A SEQUENCE of instructions that a computer can execute to
A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form
More informationProgramming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 06 Demonstration II So, in the last lecture, we have learned
More informationIntroduction to Unix
Part 2: Looking into a file Introduction to Unix Now we want to see how the files are structured. Let's look into one. more $ more fe_03_06596.txt 0.59 1.92 A-f: hello 1.96 2.97 B-m: (( hello )) 2.95 3.98
More informationLecture Notes for CS 150 Fall 2009; Version 0.5
for CS 150 Fall 2009; Version 0.5 Draft! Do not distribute without prior permission. Copyright 2001-2009 by Mark Holliday Comments, corrections, and other feedback appreciated holliday@email.wcu.edu Chapter
More informationCOMPUTER PROGRAMMING LOOPS
COMPUTER PROGRAMMING LOOPS http://www.tutorialspoint.com/computer_programming/computer_programming_loops.htm Copyright tutorialspoint.com Let's consider a situation when you want to write five times. Here
More informationshortcut Tap into learning NOW! Visit for a complete list of Short Cuts. Your Short Cut to Knowledge
shortcut Your Short Cut to Knowledge The following is an excerpt from a Short Cut published by one of the Pearson Education imprints. Short Cuts are short, concise, PDF documents designed specifically
More informationMITOCW watch?v=rvrkt-jxvko
MITOCW watch?v=rvrkt-jxvko The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationLec 3. Compilers, Debugging, Hello World, and Variables
Lec 3 Compilers, Debugging, Hello World, and Variables Announcements First book reading due tonight at midnight Complete 80% of all activities to get 100% HW1 due Saturday at midnight Lab hours posted
More informationIntroduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur
Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture - 23 Introduction to Arduino- II Hi. Now, we will continue
More informationCMSC 330: Organization of Programming Languages. Ruby Regular Expressions
CMSC 330: Organization of Programming Languages Ruby Regular Expressions 1 String Processing in Ruby Earlier, we motivated scripting languages using a popular application of them: string processing The
More informationDownload the examples: LabWeek5examples..py or download LabWeek5examples.txt and rename it as.py from the LabExamples folder or from blackboard.
NLP Lab Session Week 5 September 25, 2013 Regular Expressions and Tokenization So far, we have depended on the NLTK wordpunct tokenizer for our tokenization. Not only does the NLTK have other tokenizers,
More information