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:
|
|
- Russell Byrd
- 6 years ago
- Views:
Transcription
1 CS 1251 Page 1 Friday Friday, October 31, :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 using the spreadsheet formulas =left(), =right(), and =mid(). Javascript has two swiss army knife functions for manipulating text. They are called.substr() and.substring(). The functionality of all three of those spreadsheet functions can be reproduced by using either of those methods-- but the exact details are different between the two. The string method.substr() The first argument is where to start. This method is 0-based. It can accept negative numbers which determine a location based upon how far it is from the end. The second argument is optional. If it not included then the method will return everything from the starting index to the end of the string. This makes it easy to replicate the behavior of =right(). If the second argument is included then it stand for how far to go. It is a measure of length. 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: "My text".substr(3,2) The result is "te" My text My text start length of 2 at index 3 Let's look at how we can use.substr() to emulate the spreadsheet functions: =right("my text",3) "My text".substr(-3) Displays the last 3 characters in the string =left("my text",3) =mid("my text",4,5) "My text".substr(0,3) Displays the first 3 characters in the string "My text".substr(3,2) Displays the substring "te" The string method.substring() The first argument is where to start. This method is 0-based. It does not accept negative numbers (it treats them as if they were a 0). The second argument is optional and indicates where to stop. Think about the function as walking through the characters one by one-- start argument tells the program when to start recording characters, and the stop argument tells it where to stop-- and the computer responds instantly-- before it records that location. "My text".substr(3,5) My text My text My text * * start at stop at index 3 index 5
2 CS 1251 Page 2 The result is "te" =right("my text",3) str="my text"; str.substring(str.length-3) Displays the last 3 characters in the string =left("my text",3) "My text".substring(0,3) Displays the first 3 characters in the string =mid("my text",4,5) "My text".substring(3,5) Displays the substring "te" In computer descriptions of funtions it is common to use [ ] to indicate an optional argument. With that in mind we can summarize the information this way: =right(text, n) =left(text,n) =mid(start,stop).substr(start,[n]).substring(start,[stop]) Returns the last n characters from text Returns the first n characters from text Returns the substring starting at index start and going to index stop Returns the substring starting at index start and of length n Returns the substring starting at index start and stoping at index stop Neither 1 nor 0 based-- it's based on length Neither 1 nor 0 based-- it's based on length Both arguments are 1-based The first argument start is 0- based. The second argument n is a length Both arguments are 0-based The string method.search() We have just observed how to use numbers to extract a substring from a longer string. We can also try go in the opposite direction and find the location (a number) of a substring located inside of a longer string. On the spreadsheet side we used the function =search(<substring>,<text>) for this task. There's an equivalent on the javascript side called.search(<substring>) For example "Hello".search("ll") will return 2 (the index at which the match was found.the method.search() is case sensitive AND 0-based: Hello location that match begins It turns out that.search() can do far more than just search for a substring it can search for patterns of text. These patterns of text are called regular expressions and they are EXTREMELY useful. Regular Expressions Regular expressions are used to describe patterns. As we experiment with them you may find it very helpful to try the examples out using the tools at Some uses: Verify that entered data is in correct format
3 CS 1251 Page 3 Find a complicated text pattern Reformat text Regular expressions describe patterns of text. They are specified similarly to a string, but instead of using quotes we will use forward slashes. For example /\d/ The above is a regular expression that matches a single digit. Regular expressions are fairly similar to searches with wild cards, but there are a lot more characters with a special meaning. For example the character. Stands for ANY character (don't try to interpret it as the period). We tell.search() to use regular expressions by using the forward slashes instead of quotes: "Hello".search(/ll/); Will return the same value as "Hello".search("ll") And, "hello".search(/l./); Will look for any l followed by another character. So in this example, we'll get the same result, but consider "hello".search(/o/); which will return a 4 and "hello".search(/o./); which will return a -1 (meaning no matches). One of the cool things about regular expressions (regex's if you're friends), is that they can be STORED in a variable: var pattern=/o/; "hello".search(pattern); Will return a 4! Here are some other special characters, and combinations of characters: \d stands for any digit (0,1,2,3,4,5,6,7,8,9) So "The other day I looked for 23 pumpkins".search(/\d\d/); Will return 27, while "The other day I looked for 23 pumpkins".search(/\d\d\d/); Will return -1 because there's no place where 3 digits appear in a row. Here are some of the special characters:. Any character except newline Beginning of the string (anchor) $ End of the string (anchor) Most normal characters Same meaning \r, \n, \t carriage return newline tab \d Any digit \D Any NON-digit \s white space \S anything BUT whitespace \w any alphanumeric character [a-za-z0-9_] \W Any NON-word character Notice the back slash '\'? It changes the meaning of the symbols so \n doesn't try to search for "\n",
4 CS 1251 Page 4 instead it looks for a newline, and \s doesn't try to search for "\s", instead it tries to look for ANY single example of whitespace. Notice the lower-case/upper-case pattern in the table above. The backslash is called "escape", and it means that you "escape the normal interpretation". Escaping a special character (preceding it by \) makes it normal so if you want to match the period you can use \. Notice that some of the characters are called anchors-- these don't use up characters-- they match a condition (like being at the beginning of a string) Let's suppose we have a customer spreadsheet with phone numbers. We expect the phone number to be of the form (xxx)xxx-xxxx So how could we look for it? Let's write a function that takes the current active selection, and changes the background color of any cell that does NOT have an entry in this format: function findbadphonenumbers(){ var activerange=spreadsheetapp.getactiverange(); var numrows=activerange.getnumrows(); var phonepattern=/\(\d\d\d\)\d\d\d-\d\d\d\d$/; // Nasty isn't it? var cell; for(row =1;row<=numRows;row++){ //remember that.getcell() is 1- based! cell=activerange.getcell(row,1); var tmp = cell.getvalue(); if(typeof(tmp)=="string"){ if(tmp.search(phonepattern)==-1){ cell.setbackgroundcolor("red"); Let me explain that regular expression by putting each unit on a separate line: / beginning of regular expression start of the string \( An honest parenthesis-- could have used [(] as well \d first digit in area code \d second digit in area code \d third digit in area code \) another honest parenthesis-- could have used [)] \d First digit in the prefix \d second digit in the prefix \d final digit in the prefixt - the dash \d beginning digit of the last bit \d next digit \d next digit \d final digit $ end of the string / end of the regular expression In addition you can use "character classes" to match a collection of characters: [<put characters here>] [acgt] will match a, c, g, or t ONCE. You can INVERT the meaning by putting a at the beginning: [acgt] will match anything that is NOT an a, c, g, or t.
5 CS 1251 Page 5 metacharacters Some characters are used to control HOW the matching occurs: * 0-or more instances + 1-or more instances {n {n,m {n, {,m exactly n instances n or more, but m or less n or more no more than m Parenthesis can be used to group data at the metacharacters above, apply to them. Parenthesis can also be used to CAPTURE data. Okay some of today's lecture will be a bit redundant, but it's good to be reminded how these things work. I want to add two more anchors. Here is a review (again) of the special characters that we have: Special Characters (mostly involving backslash) Anchors:. Any character except newline \r, \n, \t carriage return newline tab \d Any digit \D Any NON-digit \s white space \S anything BUT whitespace \w any alphanumeric character [a-za-z0-9_] \W any non-alphanumeric character \( \) \\ \ \$ \. \[ \] Beginning of the string (anchor) $ End of the string (anchor) \b word boundary (this is an anchor) \B nonword boundary * 0-or more instances + 1-or more instances? 0 or 1 instances {n {n,m {n, {,m exactly n instances n or more, but m or less n or more no more than m Literal versions Metacharacters (control the matching) (we will learn a few more later on) Grouping and alternation ( left parenthesis for grouping and capture ) right parenthesis for grouping and capture
6 CS 1251 Page 6 alternation (acts like an 'or' from logic) Character Classes: [characters] characters Matches one character The characters to match When the first character in a character class it looks for the opposite - When NOT the first character it acts as a range [A-E0-3] is the same as [ABCDE0123] Subexpressions captured by parenthesis \n n is the number of the left parenthesis that defines the group. Let's do a bit more practice. Go to (If you get done early go work on Enter the string: "Jerry had 10 little lambs and 30 slices of pizza. Mary had gold bullion and a violin." Now come up with regular expressions that do the following: 1. Match a number with two digits (in this case the match should be Match a complete number of any length-- even if you don't know how many digits 3. Go to javascript console and redo 1 and 2 in javascript use a..search() to find the location of the match b..match() to find the value of the match 4. Back to the webpage and find a regular expression that matches an entire word 5. Matches a word that starts with l 6. Matches a word that start with m OR M (use a character class) 7. Matches a word that start with m OR M (use a alternation ) 8. Matches a word that starts with a capital letter 9. Matches a word that start with a capital letter but has no other capital letters 10. Match a word that is preceded by a space and starts with a capital letter 11. Match a word that is preceded by one or more spaces and starts with a capital letter 12. Matches an entire sentence 13. Matches a monetary amount of the form $3.00 or $20.00 or $ Putting it together: Let's suppose that we have a list of names, but we want to make certain that all the first letters are capitalized, unfortunately we don't know how many words are in any particular name. This is more subtle than you might think. Matching something that starts with a capital letter and is followed by lowercase letters (optionally-- we want to match I): /[A-Z][a-z]*/ But what if we want ALL our words to be of this form. This will find a word that is preceded by a space /([A-Z][a-z]*)+/ This will fail. It matches patterns like "MaryHadALittleLamb" (try it on the webpage). And since it is not anchored at the beginning it will also match a pattern like this: "so lots of lower case stuff and then MaryHadALittleLamb will be found" Try this in the inspector And the contents the array are: Do you see what happened? Index 0 shows the total match and the following indices show the
7 CS 1251 Page 7 subexpressions that matched (remember how the parenthesis are numbered?) Okay, let's make a function that looks at each word in the current selection and highlights any cell that has a word in the wrong form. function findbadnames(){ var activerange=spreadsheetapp.getactiverange(); var numrows=activerange.getnumrows(); var namepattern=/[ ]*[A-Z]([a-z])*([ ]+[A-Z]([a-z])*)*[ ]*$/; var cell; for(row =1;row<=numRows;row++){ //remember that.getcell() is 1- based! cell=activerange.getcell(row,1); var tmp = cell.getvalue(); if(typeof(tmp)=="string"){ if(tmp.search(namepattern)==-1){ cell.setbackgroundcolor("red"); So this is tricky, but not impossible to understand let's look at the regular expression: /[ ]*[A-Z]([a-z])*([ ]+[A-Z]([a-z])*)*[ ]*$/ Start of string optional collection of spaces capital letter option collection of lower case strings one or more spaces followed by a capital letter, followed by optional lower case optional spaces ignored at the end Here's what we will try it on: And here are the results: greedy versus lazy matching The symbol? can be a bit tricky. It can MODIFY another metacharacter: *? 0 or more-- lazy * 0 or more-- greedy +? 1 or more-- lazy + 1 or more--greedy? 0 or 1-- greedy
8 CS 1251 Page 8?? 0 or 1-- lazy Greedy matches eat as much as they possibly can: Lazy matches as little as possible. Let's see why this might be useful by trying to match data between parenthesis. First we need a pattern: To get the stuff inside the parenthesis: /\(.+\)/ Try using it with.match() in the console window. On an expression like this: "example (parenthesis stuff) blah" Spiffy isn't it? However there is a problem "example (parenthesis stuff) blah (more parens) blah" What happened? [have them explain] Try this modification: /\(.+?\)/ (see the difference between greedy and lazy?) There is another way to make sure the pattern matches the way that you expect: /\([)]+\)/ Greedy or lazy, we get the same result (try it) Some string methods that work with regular expressions are:.test(<regexp>) // Returns boolean (true if the string has a match, false otherwise).match<regexp).search(<regexp>) // Returns index of match.replace(<regexp>,<replacement>) // Allows for replacements flags &.match() You can modify some things about how a regexp matches by following it with some letters: /<regexp>/g /<regexp>/i global case insensitive (ignore difference between lower case and upper case) /<regexp>/m multiline (we won't cover this) the.search() function FINDS the location of the pattern and it ignores /g "hello, world".search(/l./) will return 2. "hello, world".search(/l./g) will also return 2. The.match() function returns the actual match and the parenthesis matches: "hello, world".match(/l./) will return "ll" But the global flag causes.match() to return ALL matches but to NOT return the parenthesis matches: "hello, world".match(/l./g) returns ["ll","ld"] <discuss why "lo" isnt found this has to do with HOW the pattern is found-- the simple version of the answer is that matches can't, by default, overlap> Search and Replace You can use.replace(<regexp>,<string>) to find a pattern (or more than one pattern) and replace it So, for example, let's write a function that finds every occurrence of the word "red" and replaces it with "blue" function redtoblue(mystr){ return(mystr.replace("red","blue")); function redtoblue2(mystr){
9 CS 1251 Page 9 return(mystr.replace(/red/i,"blue")); function redtoblue3(mystr){ return(mystr.replace(/red/ig,"blue")); And now consider a function that acts the same way as left trim function regexlefttrim(mystr){ return(mystr.replace(/\s+/,'')); How about a function that replaces multiple spaces with just a single space function collapsespaces(mystr){ return(mystr.replace(/[ ]+/g,' ')); [Do examples in the console] Okay. now things get cool. You can use BACK REFERENCES in the replacement string of the form $n: Let's look for a pattern of the form blah blah blah (first thing in parens) blah blah blah (second thing in parens) blah blah blah And swap the contents of the parenthesis! Recall we can find the contents of parenthesis like this: /\(.+?\)/ note the lazy matching +? Now we want to capture: /(\(.+?\))/ Next we want to find the next set of parens and capture their contents too: /(\(.+?\))(.*?)(\(.+?\))/ Now lets try a replace.replace(/(\(.+?\))(.*?)(\(.+?\))/,"$3$2$1") The best basic tutorial I found is at: We can also use to stand for "or". Let's try the regexcrossword:
Friday. remove element from beginning return its value
CS 1251 Page 1 Friday Friday, October 24, 2014 12:23 PM At the end of last class I asked the class to create a function that takes the value in row three, column 2 from a named data range, and then sets
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 informationWednesday. Wednesday, September 17, CS 1251 Page 1
CS 1251 Page 1 Wednesday Wednesday, September 17, 2014 8:20 AM Here's another good JavaScript practice site This site approaches things from yet another point of view it will be awhile before we cover
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 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 informationMonday. A few notes on homework I want ONE spreadsheet with TWO tabs
CS 1251 Page 1 Monday Sunday, September 14, 2014 2:38 PM A few notes on homework I want ONE spreadsheet with TWO tabs What has passed before We ended last class with you creating a function called givemeseven()
More informationFunctional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute
Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute Module # 02 Lecture - 03 Characters and Strings So, let us turn our attention to a data type we have
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. 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 informationWatch the video below to learn more about number formats in Excel. *Video removed from printing pages. Why use number formats?
Excel 2016 Understanding Number Formats What are number formats? Whenever you're working with a spreadsheet, it's a good idea to use appropriate number formats for your data. Number formats tell your spreadsheet
More information6.001 Notes: Section 8.1
6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything
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 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 informationITST 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 informationRegular 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 informationPerl Programming. Bioinformatics Perl Programming
Bioinformatics Perl Programming Perl Programming Regular expressions A regular expression is a pattern to be matched against s string. This results in either a failure or success. You may wish to go beyond
More informationCMPS 12A Introduction to Programming Lab Assignment 7
CMPS 12A Introduction to Programming Lab Assignment 7 In this assignment you will write a bash script that interacts with the user and does some simple calculations, emulating the functionality of programming
More informationChapter 2, Part I Introduction to C Programming
Chapter 2, Part I Introduction to C Programming C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 2016 Pearson Education, Ltd. All rights reserved. 2 2016 Pearson Education,
More informationRegular 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 informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,
More informationDr. 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 informationPaolo 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 informationFiltering 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 informationCS 230 Programming Languages
CS 230 Programming Languages 09 / 20 / 2013 Instructor: Michael Eckmann Today s Topics Questions/comments? Continue Regular expressions Matching string basics =~ (matches) m/ / (this is the format of match
More informationFriday. Last class Some of what we covered: for loop nested for loops toast. The place from which you call a function affects what it can do!
cs1251 Page 1 Friday Tuesday, February 18, 2014 3:57 PM Last class Some of what we covered: for loop nested for loops toast The place from which you call a function affects what it can do! Classes: Certain
More information(Refer Slide Time 6:48)
Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 8 Karnaugh Map Minimization using Maxterms We have been taking about
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationString Manipulation. Module 6
String Manipulation http://datascience.tntlab.org Module 6 Today s Agenda Best practices for strings in R Code formatting Escaping Formatting Base R string construction Importing strings with stringi Pattern
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 informationRecap We have been working with representing an organizational structure in a two-column configuration.
CS 1251 Page 1 Monday Monday, September 22, 2014 10:42 AM Recap We have been working with representing an organizational structure in a two-column configuration. In order to pull useful information we
More informationC 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正则表达式 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 informationProgramming for Engineers Introduction to C
Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines
More informationTroubleshooting Maple Worksheets: Common Problems
Troubleshooting Maple Worksheets: Common Problems So you've seen plenty of worksheets that work just fine, but that doesn't always help you much when your worksheet isn't doing what you want it to. This
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 informationBEGINNER PHP Table of Contents
Table of Contents 4 5 6 7 8 9 0 Introduction Getting Setup Your first PHP webpage Working with text Talking to the user Comparison & If statements If & Else Cleaning up the game Remembering values Finishing
More informationUnderstanding 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 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 informationIT441. Regular Expressions. Handling Text: DRAFT. Network Services Administration
IT441 Network Services Administration Handling Text: DRAFT Regular Expressions Searching for Text in a File Make note of the following directory: /home/ckelly/course_files/it441_files Given the file gettysburg.txt
More information"Hello" " This " + "is String " + "concatenation"
Strings About Strings Strings are objects, but there is a special syntax for writing String literals: "Hello" Strings, unlike most other objects, have a defined operation (as opposed to a method): " This
More informationPHP and MySQL for Dynamic Web Sites. Intro Ed Crowley
PHP and MySQL for Dynamic Web Sites Intro Ed Crowley Class Preparation If you haven t already, download the sample scripts from: http://www.larryullman.com/books/phpand-mysql-for-dynamic-web-sitesvisual-quickpro-guide-4thedition/#downloads
More informationAppendix. 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 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 informationPackages in Julia. Downloading Packages A Word of Caution Sawtooth, Revisited
Packages in Julia Downloading Packages A Word of Caution Sawtooth, Revisited Downloading Packages Because Julia is an open-source language, there are a ton of packages available online that enable such
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!!
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 informationRegular 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 informationIn our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.
Guide to and Hi everybody! In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. This guide focuses on two of those symbols: and. These symbols represent concepts
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationCONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction
CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want
More informationJava Programming Fundamentals - Day Instructor: Jason Yoon Website:
Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused
More information6.001 Notes: Section 15.1
6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define
More informationText. Text Actions. String Contains
Text The Text Actions are intended to refine the texts acquired during other actions, for example, from web-elements, remove unnecessary blank spaces, check, if the text matches the defined content; and
More information3 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 informationMicrosoft Office Excel 2010 Extra
Microsoft Office Excel 2010 Extra Excel Formulas İçindekiler Microsoft Office... 1 A.Introduction... 3 1.About This Tutorial... 3 About this tutorial... 3 B.Formula and Function Basics... 4 2.Simple Formulas...
More informationDescribing 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 informationPieter van den Hombergh. April 13, 2018
Intro ergh Fontys Hogeschool voor Techniek en Logistiek April 13, 2018 ergh/fhtenl April 13, 2018 1/11 Regex? are a very power, but also complex tool. There is the saying that: Intro If you start with
More informationLesson 1: Writing Your First JavaScript
JavaScript 101 1-1 Lesson 1: Writing Your First JavaScript OBJECTIVES: In this lesson you will be taught how to Use the tag Insert JavaScript code in a Web page Hide your JavaScript
More informationRio Hondo Prep Computer Applications Class
Open up document 10-1 (this is the one you worked on in the previous assignment). It should look like this: We have one column that is blank; the Avg Speed (this leg), column C. The formula for C2 is pretty
More informationEssentials for Scientific Computing: Stream editing with sed and awk
Essentials for Scientific Computing: Stream editing with sed and awk Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Stream Editing sed and awk are stream processing commands. What this means is that they are
More informationLanguage Reference Manual
TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall
More informationCS 115 Lecture 8. Selection: the if statement. Neil Moore
CS 115 Lecture 8 Selection: the if statement Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 24 September 2015 Selection Sometime we want to execute
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 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 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 informationSCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015
SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationCST 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 informationA function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).
CIT Intro to Computer Systems Lecture # (//) Functions As you probably know from your other programming courses, a key part of any modern programming language is the ability to create separate functions
More informationChapter 2 Working with Data Types and Operators
JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics
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 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 informationMore Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1
More Scripting and Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 Regular Expression Summary Regular Expression Examples Shell Scripting 2 Do not confuse filename globbing
More informationPerl. Interview Questions and Answers
and Answers Prepared by Abhisek Vyas Document Version 1.0 Team, www.sybaseblog.com 1 of 13 Q. How do you separate executable statements in perl? semi-colons separate executable statements Example: my(
More informationDOWNLOAD PDF MICROSOFT EXCEL ALL FORMULAS LIST WITH EXAMPLES
Chapter 1 : Examples of commonly used formulas - Office Support A collection of useful Excel formulas for sums and counts, dates and times, text manipularion, conditional formatting, percentages, Excel
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 informationTCL - STRINGS. Boolean value can be represented as 1, yes or true for true and 0, no, or false for false.
http://www.tutorialspoint.com/tcl-tk/tcl_strings.htm TCL - STRINGS Copyright tutorialspoint.com The primitive data-type of Tcl is string and often we can find quotes on Tcl as string only language. These
More information(Refer Slide Time: 00:23)
In this session, we will learn about one more fundamental data type in C. So, far we have seen ints and floats. Ints are supposed to represent integers and floats are supposed to represent real numbers.
More informationProgramming Project #4: A Logo Interpreter Summer 2005
CS 61A Programming Project #4: A Logo Interpreter Summer 2005 In Chapter 4 we study a Scheme interpreter written in Scheme, the metacircular evaluator. In this project we modify that evaluator to turn
More informationServer-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 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 informationStrings are actually 'objects' Strings
Strings are actually 'objects' Strings What is an object?! An object is a concept that we can encapsulate data along with the functions that might need to access or manipulate that data. What is an object?!
More informationSeparate, Split & Remove Substring & Number from Text with Excel Functions & VBA
[Editor s Note: This is a guide on how to separate, split & remove substring & numbers from text using Excel Functions and VBA. Examples of substring functions are CHAR, FIND, LEFT, LOWER, MID, PROPER,
More informationUNIX II:grep, awk, sed. October 30, 2017
UNIX II:grep, awk, sed October 30, 2017 File searching and manipulation In many cases, you might have a file in which you need to find specific entries (want to find each case of NaN in your datafile for
More informationProblem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur
Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 18 Switch Statement (Contd.) And Introduction to
More informationStrings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics
Strings Strings and their methods Produced by: Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Primitive Types: char Object Types: String Primitive vs Object Types
More informationsuccesses 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 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 informationTitle:[ Variables Comparison Operators If Else Statements ]
[Color Codes] Environmental Variables: PATH What is path? PATH=$PATH:/MyFolder/YourStuff?Scripts ENV HOME PWD SHELL PS1 EDITOR Showing default text editor #!/bin/bash a=375 hello=$a #No space permitted
More informationScripting Languages. Diana Trandabăț
Scripting Languages Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture What is Perl? How to install Perl? How to write Perl progams? How to run a Perl program? perl
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday
More informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More informationGENERAL MATH FOR PASSING
GENERAL MATH FOR PASSING Your math and problem solving skills will be a key element in achieving a passing score on your exam. It will be necessary to brush up on your math and problem solving skills.
More informationFormulas, LookUp Tables and PivotTables Prepared for Aero Controlex
Basic Topics: Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex Review ribbon terminology such as tabs, groups and commands Navigate a worksheet, workbook, and multiple workbooks Prepare
More informationIDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1
IDM 232 Scripting for Interactive Digital Media II IDM 232: Scripting for IDM II 1 PHP HTML-embedded scripting language IDM 232: Scripting for IDM II 2 Before we dive into code, it's important to understand
More informationITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University
ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 07: Data Input and Output Readings: Chapter 4 Input /Output Operations A program needs
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 informationLESSON 4. The DATA TYPE char
LESSON 4 This lesson introduces some of the basic ideas involved in character processing. The lesson discusses how characters are stored and manipulated by the C language, how characters can be treated
More informationCST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB
Student Name: Lab Section: Boot Process and GRUB 1 Due Date - Upload to Blackboard by 8:30am Monday April 16, 2012 Submit the completed lab to Blackboard following the Rules for submitting Online Labs
More informationCOMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.
COMP1730/COMP6730 Programming for Scientists Data: Values, types and expressions. Lecture outline * Data and data types. * Expressions: computing values. * Variables: remembering values. What is data?
More informationSoftware Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore
Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Lecture 04 Software Test Automation: JUnit as an example
More information