Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)

Size: px
Start display at page:

Download "Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)"

Transcription

1 Bioinformatics Programming EE, NCKU Tien-Hao Chang (Darby Chang) 1

2 Regular Expression 2

3 3

4 Text patterns and matches A regular expression, or regex for short, is a pattern describing a certain amount of text In this slide, regular expressions are highlighted as regex it is the most basic pattern, simply matching the literal text regex (highlighted in this slide) I will use the term string to indicate the text that I am applying the regular expression to and will be highlighted as string 4

5 Literal characters The most basic regular expression consists of a single literal character, ex: a match the first occurrence of that character in the string on Jack is a boy Jack is a boy, not Jack is a boy In this slide, I ll use a shorter notation sometimes a: Jack is a boy Eleven characters with special meanings: [ \ ^ $.? * + ( ) metacharacters escape metacharacters with a backslash use 1\+1=2 to match 1+1=2 5

6 Character classes/sets Match only one out of several characters to match an a or an e, use [ae] you could use this in gr[ae]y to match gray or grey a character class matches only a single character gr[ae]y will not match graay or graey the order does not matter Use a hyphen to specify a range of characters [0-9] matches a single digit between 0 and 9 combine ranges and single characters [0-9a-fA-F] combine ranges and single characters [0-9a-fxA-FX] A caret after the opening square bracket negates the class q[^x] matches qu in question but does not match Iraq since there is no character after the q for the negated character class to match 6

7 Shorthand character classes \d matches a single character that is a digit \w matches a word character alphanumeric characters plus underscore \s matches a whitespace character includes tabs and line breaks \S not \s The actual characters matched by the shorthands depends on the software you re using $ man perlre 7

8 Non-printable characters Use special character sequences to put non-printable characters \t for tab (ASCII 0x09) \r for carriage return (0x0D) \n for line feed (0x0A) Remember that Windows text files use \r\n to terminate lines, while UNIX text files use \n Use \xff to match a specify character by its hexadecimal index in the character set \xa9 matches the copyright symbol \uffff for a Unicode character (if supported) \u20a0 matches the euro currency sign 8

9 The dot The dot,., matches (almost) any character The dot matches a single character, except line break characters a short for [^\n] gr.y matches gray, grey, gr%y, etc Most regex engines have a dot matches all or single line mode that makes the dot match any single character, including line breaks 9

10 Anchors Anchors do not match any characters but match a position ^ matches at the start of the string $ matches at the end of the string Most regex engines have a multi-line mode that makes ^ match after any line break, and $ before any line break b$ matches only bob \b matches at a word boundary a word boundary is a position between a character that can be matched by \w and a character that cannot be matched by \w \b also matches at the start and/or end of the string if the first and/or last characters in the string are word characters \B matches at every position where \b cannot match \bis\b: This island is beautiful 10

11 Alternation Alternation is the regular expression equivalent of or cat dog: About cats and dogs You can add as many alternatives as you want cat dog mouse fish 11

12 Repetition? makes the preceding token in the regular expression optional colou?r matches colour or color * matches the preceding token zero or more times + matches the preceding token once or more <[A-Za-z][A-Za-z0-9]*> matches an HTML tag without any attributes <[A-Za-z0-9]+> is easier to write but matches invalid tags such as <1> {} specifies a specific amount of repetition \b[1-9][0-9]{3}\b matches \b[1-9][0-9]{2,4}\b matches

13 Greedy and lazy repetition The repetition operators or quantifiers are greedy They will expand the match as far as they can, and only give back if they must to satisfy the remainder of the regex <.+>: This is a <EM>first</EM> test Place a question mark after the quantifier to make it lazy, i.e., stop matching as soon as possible <.+?>: This is a <EM>first</EM> test A better solution is to use <[^<>]+> to quickly match an HTML tag without regard to attributes the negated character class is more specific than the dot, which helps the regex engine find matches quickly 13

14 Grouping and backreferences Place round brackets, (), around multiple tokens to group them together you can then apply a quantifier to the group Set(Value)? matches Set or SetValue Round brackets create a capturing group the above example has one group how to access the group s contents depends on the software or programming language you re using Group zero always contains the entire regex match Set(Value)?: SetValue, then $0 = SetValue, $1 = Value Set(Value)?: Set, then or $0 = Set, $1 is nothing Use the special syntax Set(?:Value)? to group tokens without creating a capturing group more efficient if you don t need the contents 14

15 Look-around Look-around is a special kind of group The tokens inside the group are matched normally, but then the regex engine makes the group give up its match and keeps only the result Look-around matches a position, just like anchors q(?=u) matches question, but not Iraq (?=u) match at each position in the string before a u u is not part of the overall regex match positive look-ahead q(?!u) matches Iraq but not question negative look-ahead (?<=a)b matches abc positive look-behind (?<!a)b fails to match abc negative look-behind 15

16 Reference Regular Expression Quick Start 16

17 We have done a lot of exercises 17

18 Now, let s Talk about Bioinformatics programming in real cases 18

19 Sequence alignment We have learnt/implemented it twice dynamic programming longest common sub-string/sub-sequence sequence alignment DNA/protein sequence residue substitution We know that time complexity is O(n2) backtracking, alternative alignments That s all? Theoretical Applicative No! There are always better algorithms. That s why we always have new papers to read. 19

20 Sequence alignment Some advanced ideas Band alignment Arbitrary region When is this point never considered? 20

21 Seq = AGATCGAT AAA AAC. AGA 1. ATC 3. CGA 5. GAT 2 6 TCG 4. TTT The state-of-the-art solutions: seeding and extension. 21

22 This is not Bioinformatics algorithm 22

23 Protein clustering In Out a FASTA file and an integer k k clusters of proteins Requirement - invoke BLAST - complexity/teamwork report - using Perl would be the best Bonus - k-means algorithm - invoke clustering package 23

24 Deadline 2010/5/4 23:59 Zip your code, step-by-step README, complexity analyses and anything worthy extra credit. to 24

25 BLAST Download protein sequence from UniProt $ wget -o ytf.fa ' ription+factor+and+reviewed%3ayes&force=yes&format=fasta A Unix tip using grep and regular expression $ grep '^>' ytf.fa wc l # how many sequences $ grep -c '^>' ytf.fa # a better version Download BLAST from NCBI I prefer this version ftp://ftp.ncbi.nlm.nih.gov/blast/executables/release/latest/blast ia32-linux.tar.gz Execution $ format db i ytf.fa # building indices $ blastall -d ytf.fa -i ytf.fa -p blastp > ytf.bo # default output $ blastall -d ytf.fa -i ytf.fa -m 6 -p blastp > ytf.bo # tabular output 25

PowerGREP. Manual. Version October 2005

PowerGREP. 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 information

Version November 2017

Version November 2017 Version 5.1.3 7 November 2017 Published by Just Great Software Co. Ltd. Copyright 2002 2017 Jan Goyvaerts. All rights reserved. PowerGREP and Just Great Software are trademarks of Jan Goyvaerts i Table

More information

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 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 information

Regular 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 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 information

successes without magic London,

successes without magic London, (\d)(?:\u0020 \u0209 \u202f \u200a){0,1}((m mm cm km V mv µv l ml C Nm A ma bar s kv Hz khz M Hz t kg g mg W kw MW Ah mah N kn obr min µm µs Pa MPa kpa hpa mbar µf db)\b) ^\t*'.+?' => ' (\d+)(,)(\d+)k

More information

Regular 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) 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 information

Regular 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 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 information

Paolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems

Paolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems aim to facilitate the solution of text manipulation problems are symbolic notations used to identify patterns in text; are supported by many command line tools; are supported by most programming languages;

More information

Lecture 18 Regular Expressions

Lecture 18 Regular Expressions Lecture 18 Regular Expressions In this lecture Background Text processing languages Pattern searches with grep Formal Languages and regular expressions Finite State Machines Regular Expression Grammer

More information

Introduction to Regular Expressions Version 1.3. Tom Sgouros

Introduction 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 information

Regular Expressions. Perl PCRE POSIX.NET Python Java

Regular 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 information

Regular 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 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 information

The Little Regular Expressionist

The Little Regular Expressionist The Little Regular Expressionist Vilja Hulden August 2016 v0.1b CC-BY-SA 4.0 This little pamphlet, which is inspired by The Little Schemer by Daniel Friedman and Matthias Felleisen, aims to serve as a

More information

Regular Expressions!!

Regular 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 information

Appendix. As a quick reference, here you will find all the metacharacters and their descriptions. Table A-1. Characters

Appendix. As a quick reference, here you will find all the metacharacters and their descriptions. Table A-1. Characters Appendix As a quick reference, here you will find all the metacharacters and their descriptions. Table A-1. Characters. Any character [] One out of an inventory of characters [ˆ] One not in the inventory

More information

This page covers the very basics of understanding, creating and using regular expressions ('regexes') in Perl.

This 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 information

Perl Regular Expressions. Perl Patterns. Character Class Shortcuts. Examples of Perl Patterns

Perl 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 information

Regex, Sed, Awk. Arindam Fadikar. December 12, 2017

Regex, 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 information

Getting to grips with Unix and the Linux family

Getting to grips with Unix and the Linux family Getting to grips with Unix and the Linux family David Chiappini, Giulio Pasqualetti, Tommaso Redaelli Torino, International Conference of Physics Students August 10, 2017 According to the booklet At this

More information

Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Regular Expressions. Todd Kelley CST8207 Todd Kelley 1 Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 POSIX character classes Some Regular Expression gotchas Regular Expression Resources Assignment 3 on Regular Expressions

More information

Regex Guide. Complete Revolution In programming For Text Detection

Regex 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 information

Introduction to regular expressions

Introduction to regular expressions 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

More information

=~ determines to which variable the regex is applied. In its absence, $_ is used.

=~ 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 information

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

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 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 information

Regular Expressions Explained

Regular Expressions Explained Found at: http://publish.ez.no/article/articleprint/11/ Regular Expressions Explained Author: Jan Borsodi Publishing date: 30.10.2000 18:02 This article will give you an introduction to the world of regular

More information

CS 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 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 information

HEP Computing Part II Scripting Marcella Bona

HEP Computing Part II Scripting Marcella Bona HEP Computing Part II Scripting Marcella Bona Lectures 2 Adrian Bevan m.bona@qmul.ac.uk 1 Lecture 2 Introduction to scripts: what are they, how do you write and run them? Using bash Special Characters.

More information

Version June 2017

Version June 2017 Version 2.7.0 19 June 2017 Published by Just Great Software Co. Ltd. Copyright 2009 2017 Jan Goyvaerts. All rights reserved. RegexMagic and Just Great Software are trademarks of Jan Goyvaerts i Table of

More information

正则表达式 Frank from https://regex101.com/

正则表达式 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 information

Compiler Design. 2. Regular Expressions & Finite State Automata (FSA) Kanat Bolazar January 21, 2010

Compiler 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 information

Index. caps method, 180 Character(s) base, 161 classes

Index. caps method, 180 Character(s) base, 161 classes A Abjads, 160 Abstract syntax tree (AST), 3 with action objects, 141 143 definition, 135 Action method for integers converts, 172 173 S-Expressions, 171 Action objects ASTs, 141 142 defined, 137.made attribute,

More information

https://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 information

Regular Expressions. Regular Expression Syntax in Python. Achtung!

Regular 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 information

Computer Systems and Architecture

Computer 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 information

LING115 Lecture Note Session #7: Regular Expressions

LING115 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 information

Lecture 2. Regular Expression Parsing Awk

Lecture 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 information

Understanding Regular Expressions, Special Characters, and Patterns

Understanding Regular Expressions, Special Characters, and Patterns APPENDIXA Understanding Regular Expressions, Special Characters, and Patterns This appendix describes the regular expressions, special or wildcard characters, and patterns that can be used with filters

More information

Filtering Service

Filtering Service Secure E-Mail Gateway (SEG) Service Administrative Guides Email Filtering Service Regular Expressions Overview Regular Expressions Overview AT&T Secure E-Mail Gateway customers can use Regular Expressions

More information

Using Lex or Flex. Prof. James L. Frankel Harvard University

Using Lex or Flex. Prof. James L. Frankel Harvard University Using Lex or Flex Prof. James L. Frankel Harvard University Version of 1:07 PM 26-Sep-2016 Copyright 2016, 2015 James L. Frankel. All rights reserved. Lex Regular Expressions (1 of 4) Special characters

More information

Computer Systems and Architecture

Computer Systems and Architecture Computer Systems and Architecture Regular Expressions Bart Meyers University of Antwerp August 29, 2012 Outline What? Tools Anchors, character sets and modifiers Advanced Regular expressions Exercises

More information

Learning 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 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 information

STATS Data analysis using Python. Lecture 0: Introduction and Administrivia

STATS 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 information

Regular Expressions in Practice

Regular Expressions in Practice University of Kentucky UKnowledge Library Presentations University of Kentucky Libraries 12-20-2016 Regular Expressions in Practice Kathryn Lybarger University of Kentucky, kathryn.lybarger@uky.edu Click

More information

Regular Expressions Primer

Regular Expressions Primer Regular Expressions Primer Jeremy Stephens Computer Systems Analyst Department of Biostatistics December 18, 2015 What are they? Regular expressions are a way to describe patterns in text. Why use them?

More information

Pattern Matching. An Introduction to File Globs and Regular Expressions

Pattern Matching. An Introduction to File Globs and Regular Expressions Pattern Matching An Introduction to File Globs and Regular Expressions Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your disadvantage, there are two different forms of patterns

More information

CS Unix Tools & Scripting

CS Unix Tools & Scripting Cornell University, Spring 2014 1 February 7, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater Regular Expression A new level of mastery over your data. Pattern matching

More information

Pattern Matching. An Introduction to File Globs and Regular Expressions. Adapted from Practical Unix and Programming Hunter College

Pattern Matching. An Introduction to File Globs and Regular Expressions. Adapted from Practical Unix and Programming Hunter College Pattern Matching An Introduction to File Globs and Regular Expressions Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your

More information

System & Network Engineering. Regular Expressions ESA 2008/2009. Mark v/d Zwaag, Eelco Schatborn 22 september 2008

System & Network Engineering. Regular Expressions ESA 2008/2009. Mark v/d Zwaag, Eelco Schatborn 22 september 2008 1 Regular Expressions ESA 2008/2009 Mark v/d Zwaag, Eelco Schatborn eelco@os3.nl 22 september 2008 Today: Regular1 Expressions and Grammars Formal Languages Context-free grammars; BNF, ABNF Unix Regular

More information

CSC 467 Lecture 3: Regular Expressions

CSC 467 Lecture 3: Regular Expressions CSC 467 Lecture 3: Regular Expressions Recall How we build a lexer by hand o Use fgetc/mmap to read input o Use a big switch to match patterns Homework exercise static TokenKind identifier( TokenKind token

More information

Lecture 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. 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 information

JavaScript Functions, Objects and Array

JavaScript Functions, Objects and Array JavaScript Functions, Objects and Array Defining a Function A definition starts with the word function. A name follows that must start with a letter or underscore, followed by any number of letters, digits,

More information

STREAM EDITOR - REGULAR EXPRESSIONS

STREAM EDITOR - REGULAR EXPRESSIONS STREAM EDITOR - REGULAR EXPRESSIONS http://www.tutorialspoint.com/sed/sed_regular_expressions.htm Copyright tutorialspoint.com It is the regular expressions that make SED powerful and efficient. A number

More information

Regular expressions: Text editing and Advanced manipulation. HORT Lecture 4 Instructor: Kranthi Varala

Regular expressions: Text editing and Advanced manipulation. HORT Lecture 4 Instructor: Kranthi Varala Regular expressions: Text editing and Advanced manipulation HORT 59000 Lecture 4 Instructor: Kranthi Varala Simple manipulations Tabular data files can be manipulated at a columnlevel. cut: Divide file

More information

Regular Expressions. Regular expressions match input within a line Regular expressions are very different than shell meta-characters.

Regular Expressions. Regular expressions match input within a line Regular expressions are very different than shell meta-characters. ULI101 Week 09 Week Overview Regular expressions basics Literal matching.wildcard Delimiters Character classes * repetition symbol Grouping Anchoring Search Search and replace in vi Regular Expressions

More information

Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)

Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang) Bioinformatics Programming EE, NCKU Tien-Hao Chang (Darby Chang) 1 Tree 2 A Tree Structure A tree structure means that the data are organized so that items of information are related by branches 3 Definition

More information

Last Time. Strings. Example. Strings. Example. We started talking about collections. Strings, Regex, Web Response

Last Time. Strings. Example. Strings. Example. We started talking about collections. Strings, Regex, Web Response Last Time We started talking about collections o Hash tables o ArrayLists Strings, Regex, Web Response 9/27/05 CS360 Windows Programming 1 9/27/05 CS360 Windows Programming 2 Let s look at the example

More information

Regular Expressions: The Power of Perl

Regular Expressions: The Power of Perl Regular Expressions: The Power of Perl 1. What is a regular expression (regex)? - it is a description for a group of characters you want to search for in a string, a file, a website, etc... - think of

More information

Cisco Common Classification Policy Language

Cisco Common Classification Policy Language CHAPTER34 Cisco Common Classification Policy Language (C3PL) is a structured replacement for feature-specific configuration commands. C3PL allows you to create traffic policies based on events, conditions,

More information

Lecture 11: Regular Expressions. LING 1330/2330: Introduction to Computational Linguistics Na-Rae Han

Lecture 11: Regular Expressions. LING 1330/2330: Introduction to Computational Linguistics Na-Rae Han Lecture 11: Regular Expressions LING 1330/2330: Introduction to Computational Linguistics Na-Rae Han Outline Language and Computers, Ch.4 Searching 4.4 Searching semi-structured data with regular expressions

More information

Effective Programming Practices for Economists. 17. Regular Expressions

Effective 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 information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

Regular Expressions. using REs to find patterns. implementing REs using finite state automata. Sunday, 4 December 11

Regular Expressions. using REs to find patterns. implementing REs using finite state automata. Sunday, 4 December 11 Regular Expressions using REs to find patterns implementing REs using finite state automata REs and FSAs Regular expressions can be viewed as a textual way of specifying the structure of finite-state automata

More information

Using Microsoft Excel

Using Microsoft Excel Using Microsoft Excel Excel contains numerous tools that are intended to meet a wide range of requirements. Some of the more specialised tools are useful to people in certain situations while others have

More information

DQ Analyzer 9. Cheat Sheets. Read the most up-to-date documentation for the latest Ataccama release online at docs.ataccama.com

DQ Analyzer 9. Cheat Sheets. Read the most up-to-date documentation for the latest Ataccama release online at docs.ataccama.com DQ Analyzer 9 Cheat Sheets Copyright 2007 2015 by Ataccama. All rights reserved. Read the most up-to-date documentation for the latest Ataccama release online at docs.ataccama.com Table of Contents Table

More information

Regular Expressions. Steve Renals (based on original notes by Ewan Klein) ICL 12 October Outline Overview of REs REs in Python

Regular 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 information

Regular expressions. LING78100: Methods in Computational Linguistics I

Regular 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 information

DATA STRUCTURE AND ALGORITHM USING PYTHON

DATA 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 information

ITST Searching, Extracting & Archiving Data

ITST Searching, Extracting & Archiving Data ITST 1136 - Searching, Extracting & Archiving Data Name: Step 1 Sign into a Pi UN = pi PW = raspberry Step 2 - Grep - One of the most useful and versatile commands in a Linux terminal environment is the

More information

Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub

Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub 2 Regular expressions

More information

Table ofcontents. Preface. 1: Introduction to Regular Expressions xv

Table 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 information

More Details about Regular Expressions

More 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 information

CST Lab #5. Student Name: Student Number: Lab section:

CST Lab #5. Student Name: Student Number: Lab section: CST8177 - Lab #5 Student Name: Student Number: Lab section: Working with Regular Expressions (aka regex or RE) In-Lab Demo - List all the non-user accounts in /etc/passwd that use /sbin as their home directory.

More information

RegExpr:Review & Wrapup; Lecture 13b Larry Ruzzo

RegExpr: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 information

A program that performs lexical analysis may be termed a lexer, tokenizer, or scanner, though scanner is also a term for the first stage of a lexer.

A program that performs lexical analysis may be termed a lexer, tokenizer, or scanner, though scanner is also a term for the first stage of a lexer. Compiler Design A compiler is computer software that transforms computer code written in one programming language (the source language) into another programming language (the target language). The name

More information

Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book. Source Code

Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book. Source Code Contents Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Source Code Errata p2p.wrox.com xxi xxi xxii xxii xxiii xxiii xxiv

More information

X Language Definition

X Language Definition X Language Definition David May: November 1, 2016 The X Language X is a simple sequential programming language. It is easy to compile and an X compiler written in X is available to simplify porting between

More information

CSE 154 LECTURE 11: REGULAR EXPRESSIONS

CSE 154 LECTURE 11: REGULAR EXPRESSIONS CSE 154 LECTURE 11: REGULAR EXPRESSIONS What is form validation? validation: ensuring that form's values are correct some types of validation: preventing blank values (email address) ensuring the type

More information

perlrebackslash - Perl Regular Expression Backslash Sequences and Escapes

perlrebackslash - Perl Regular Expression Backslash Sequences and Escapes NAME DESCRIPTION The backslash perlrebackslash - Perl Regular Expression Backslash Sequences and Escapes The top level documentation about Perl regular expressions is found in perlre. This document describes

More information

Structure of Programming Languages Lecture 3

Structure 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 information

Java Basic Datatypees

Java Basic Datatypees Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,

More information

FILTERS USING REGULAR EXPRESSIONS grep and sed

FILTERS USING REGULAR EXPRESSIONS grep and sed FILTERS USING REGULAR EXPRESSIONS grep and sed We often need to search a file for a pattern, either to see the lines containing (or not containing) it or to have it replaced with something else. This chapter

More information

A lexical analyzer generator for Standard ML. Version 1.6.0, October 1994

A lexical analyzer generator for Standard ML. Version 1.6.0, October 1994 A lexical analyzer generator for Standard ML. Version 1.6.0, October 1994 Andrew W. Appel 1 James S. Mattson David R. Tarditi 2 1 Department of Computer Science, Princeton University 2 School of Computer

More information

Outline CS4120/4121. Compilation in a Nutshell 1. Administration. Introduction to Compilers Andrew Myers. HW1 out later today due next Monday.

Outline CS4120/4121. Compilation in a Nutshell 1. Administration. Introduction to Compilers Andrew Myers. HW1 out later today due next Monday. CS4120/4121 Introduction to Compilers Andrew Myers Lecture 2: Lexical Analysis 31 August 2009 Outline Administration Compilation in a nutshell (or two) What is lexical analysis? Writing a lexer Specifying

More information

Java Notes. 10th ICSE. Saravanan Ganesh

Java Notes. 10th ICSE. Saravanan Ganesh Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses

More information

Innovative User Group Conference 2009 Anaheim 1

Innovative User Group Conference 2009 Anaheim 1 Slide 1 Using Regular Expressions in Create Lists Huntington Library, Art Collections, and Botanical Gardens San Marino, California Slide 2 Why this presentation? Regular expressions in Create Lists are

More information

EXPERIMENT NO : M/C Lenovo Think center M700 Ci3,6100,6th Gen. H81, 4GB RAM,500GB HDD

EXPERIMENT NO : M/C Lenovo Think center M700 Ci3,6100,6th Gen. H81, 4GB RAM,500GB HDD GROUP - B EXPERIMENT NO : 06 1. Title: Write a program using Lex specifications to implement lexical analysis phase of compiler to generate tokens of subset of Java program 2. Objectives : - To understand

More information

Introduction to Unix

Introduction 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 information

KU Compilerbau - Programming Assignment

KU Compilerbau - Programming Assignment 716.077 KU Compilerbau - Programming Assignment Univ.-Prof. Dr. Franz Wotawa, Birgit Hofer Institute for Software Technology, Graz University of Technology April 20, 2011 Introduction During this semester

More information

Regular Expression Reference

Regular Expression Reference APPENDIXB PCRE Regular Expression Details, page B-1 Backslash, page B-2 Circumflex and Dollar, page B-7 Full Stop (Period, Dot), page B-8 Matching a Single Byte, page B-8 Square Brackets and Character

More information

CSE528 Natural Language Processing Venue:ADB-405 Topic: Regular Expressions & Automata. www. l ea rn ersd esk.weeb l y. com

CSE528 Natural Language Processing Venue:ADB-405 Topic: Regular Expressions & Automata. www. l ea rn ersd esk.weeb l y. com CSE528 Natural Language Processing Venue:ADB-405 Topic: Regular Expressions & Automata Prof. Tulasi Prasad Sariki, SCSE, VIT Chennai Campus www. l ea rn ersd esk.weeb l y. com Contents NLP Example: Chat

More information

Sequence Alignment: BLAST

Sequence Alignment: BLAST E S S E N T I A L S O F N E X T G E N E R A T I O N S E Q U E N C I N G W O R K S H O P 2015 U N I V E R S I T Y O F K E N T U C K Y A G T C Class 6 Sequence Alignment: BLAST Be able to install and use

More information

Describing Languages with Regular Expressions

Describing Languages with Regular Expressions University of Oslo : Department of Informatics Describing Languages with Regular Expressions Jonathon Read 25 September 2012 INF4820: Algorithms for AI and NLP Outlook How can we write programs that handle

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Ray Pereda Unicon Technical Report UTR-02. February 25, Abstract

Ray Pereda Unicon Technical Report UTR-02. February 25, Abstract iflex: A Lexical Analyzer Generator for Icon Ray Pereda Unicon Technical Report UTR-02 February 25, 2000 Abstract iflex is software tool for building language processors. It is based on flex, a well-known

More information

Here's an example of how the method works on the string "My text" with a start value of 3 and a length value of 2:

Here's an example of how the method works on the string My text with a start value of 3 and a length value of 2: CS 1251 Page 1 Friday Friday, October 31, 2014 10:36 AM Finding patterns in text A smaller string inside of a larger one is called a substring. You have already learned how to make substrings in the spreadsheet

More information

Regular Expressions for Information Processing in ABAP. Ralph Benzinger SAP AG

Regular Expressions for Information Processing in ABAP. Ralph Benzinger SAP AG Regular Expressions for Information Processing in ABAP Ralph Benzinger SAP AG Regular Expression Primer Using Regular Expressions in ABAP Working with Regular Expressions Ubiquitous Text Processing (1)

More information

Using Microsoft Excel

Using Microsoft Excel Using Microsoft Excel Excel contains numerous tools that are intended to meet a wide range of requirements. Some of the more specialised tools are useful to only certain types of people while others have

More information

Tips and Tricks for Making the Most of Create Lists

Tips and Tricks for Making the Most of Create Lists Tips and Tricks for Making the Most of Create Lists Matching and More Mike Monaco Coordinator, Cataloging Services The University of Akron mmonaco@uakron.edu OH-IUG October 12, 2018 The University of Akron

More information

Regular 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 [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 information

ML 4 A Lexer for OCaml s Type System

ML 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 information