Regular Expressions Nils Murrugarra

Slides:



Advertisements
Similar presentations
MIPS Coding. Exercise 1 4/17/2015week04-3.ppt2 Suppose we have three arrays, A, B, C, all of size 10. Now we want to set C[i] = min(A[i], B[i]) for all.
Advertisements

Chapter 14 Perl-Compatible Regular Expressions Part 1.
Roll Dice Draw Tens Ones Standard Form Expanded Form
Data Manipulation & Regular Expressions CSCI 215.
Exercise Exercise3.1 8 Exercise3.1 9 Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise6.1 7 Exercise6.1 8 Exercise6.1 9.
Презентація за розділом “Гумористичні твори”
Центр атестації педагогічних працівників 2014
Галактики і квазари.
Характеристика ІНДІЇ.
Процюк Н.В. вчитель початкових класів Боярської ЗОШ І – ІІІ ст №4
Compiler Principles Winter Compiler Principles Exercises on scanning & top-down parsing Roman Manevich Ben-Gurion University.
REGULAR EXPRESSIONS CHAPTER 14. REGULAR EXPRESSIONS A coded pattern used to search for matching patterns in text strings Commonly used for data validation.
1 Perl Regular Expressions in SAS 9 Ruth Yuee Zhang, CFE Jan 10, 2005.
1 DoD Cardholder Self Registration November 21, 2008.
Algebra I Chapter 10 Review
Sys.Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 18: Regular Expressions in PHP.
PHP Using Strings 1. Replacing substrings (replace certain parts of a document template; ex with client’s name etc) mixed str_replace (mixed $needle,
Post-Module JavaScript BTM 395: Internet Programming.
Linear Inequalities and Absolute Value Inequalities.
Chapter 21 Exact Differential Equation Chapter 2 Exact Differential Equation.
Духовні символи Голосіївського району
JavaScript III ECT 270 Robin Burke. Outline Validation examples password more complex Form validation Regular expressions.
Java Script Pattern Matching Using Regular Expressions.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
Sum and Difference Formulas...using the sum and difference formula to solve trigonometric equation.
Chapter 21 Exact Differential Equation Chapter 2 Exact Differential Equation.
Write using exponents. Example 2-1a Answer:The base is 6. It is a factor 4 times, so the exponent is 4.
Lab 6: Geocoding You have received a dBase file that contains the address list of over 500 homes in your neighborhood that have had reports of lead poisoning.
Chapter 8 Systems of Linear Equations in Two Variables Section 8.3.
Perl-Compatible Regular Expressions Part 1
Multiply using the expanded form
BACK SOLUTION:
Solve: 1. 4<
2-Digit Subtraction.
What is an equation? An equation is a mathematical statement that two expressions are equal. For example, = 7 is an equation. Note: An equation.
مديريت موثر جلسات Running a Meeting that Works
Проф. д-р Васил Цанов, Институт за икономически изследвания при БАН
ЗУТ ПРОЕКТ на Закон за изменение и допълнение на ЗУТ
О Б Щ И Н А С И Л И С Т Р А П р о е к т Б ю д ж е т г.
Електронни услуги на НАП
Боряна Георгиева – директор на
РАЙОНЕН СЪД - БУРГАС РАБОТНА СРЕЩА СЪС СЪДЕБНИТЕ ЗАСЕДАТЕЛИ ПРИ РАЙОНЕН СЪД – БУРГАС 21 ОКТОМВРИ 2016 г.
Сътрудничество между полицията и другите специалисти в България
Съобщение Ръководството на НУ “Христо Ботев“ – гр. Елин Пелин
НАЦИОНАЛНА АГЕНЦИЯ ЗА ПРИХОДИТЕ
ДОБРОВОЛЕН РЕЗЕРВ НА ВЪОРЪЖЕНИТЕ СИЛИ НА РЕПУБЛИКА БЪЛГАРИЯ
Съвременни софтуерни решения
ПО ПЧЕЛАРСТВО ЗА ТРИГОДИШНИЯ
от проучване на общественото мнение,
Васил Големански Ноември, 2006
Програма за развитие на селските райони
ОПЕРАТИВНА ПРОГРАМА “АДМИНИСТРАТИВЕН КАПАЦИТЕТ”
БАЛИСТИКА НА ТЯЛО ПРИ СВОБОДНО ПАДАНЕ В ЗЕМНАТА АТМОСФЕРА
МЕДИЦИНСКИ УНИВЕРСИТЕТ – ПЛЕВЕН
Стратегия за развитие на клъстера 2015
Моето наследствено призвание
Правна кантора “Джингов, Гугински, Кючуков & Величков”
Безопасност на движението
Two Types of Factorising
Multiply using the area model
POWER CHALLENGES Several Ways To Solve 7 CHALLENGES.
Multiply using the area model
Ben-Gurion University
Trigonometric Equations
11-5 Solving Rational Equations
Optimization & Quadratics
Presentation transcript:

Regular Expressions Nils Murrugarra

Exercise 1 Write a regular expression that will match a time/clock hh:mm:ss pattern. Examples: "00:00:15" is valid "0:56:25" is not valid “11:15:09" is valid "15:96:22" is not valid 2 Solution: /([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])/ Solving … Solution2: /([01]\d|2[0-3]):([0-5]\d):([0-5]\d)/

Exercise 1 - Solution // time echo "Example Time "; $subject="00:00:15 0:56:25 95:00:25 11:15:09 15:96:22 20:15:10 "; $pattern = "/([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])/"; if (preg_match_all($pattern, $subject, $result, PREG_OFFSET_CAPTURE)): echo "$pattern was found: \n"; print_r($result); nl(); endif; 3

Exercise 1 - Solution 4 TimeAccept? 00:00:15Yes 0:56:25No 95:00:25No 11:15:09Yes 15:96:22No 20:15:10Yes Run Program … ClickClick

Exercise 1 - Report/Answers Array ( [0] => Array ( [0] => Array ( [0] => 00:00:15 [1] => 0 ) [1] => Array ( [0] => 11:15:09 [1] => 26 ) [2] => Array ( [0] => 20:15:10 [1] => 44 ) ) [1] => Array ( [0] => Array ( [0] => 00 [1] => 0 ) [1] => Array ( [0] => 11 [1] => 26 ) [2] => Array ( [0] => 20 [1] => 44 ) ) [2] => Array ( [0] => Array ( [0] => 00 [1] => 3 ) [1] => Array ( [0] => 15 [1] => 29 ) [2] => Array ( [0] => 15 [1] => 47 ) ) [3] => Array ( [0] => Array ( [0] => 15 [1] => 6 ) [1] => Array ( [0] => 09 [1] => 32 ) [2] => Array ( [0] => 10 [1] => 50 ) ) 5

Exercise 2 Write a regular expression that will match a zip code. The zip pattern may be like "16059" or the expanded form of " ". If there is a dash after the 5 digits then there must follow exactly 4 digits. Examples: "15221-abcd " is not valid "12345 " is valid “ " is valid “ “ is not valid 6 Solution: /\d{5}(-\d{4})?/ Solving …

Exercise 2 - Solution //zip code echo "Example Zip-code "; $subject="15221-abcd "; $pattern = "/\d{5}(-\d{4})?/"; if (preg_match_all($pattern, $subject, $result, PREG_OFFSET_CAPTURE)): echo "$pattern was found: \n"; print_r($result); nl(); endif; 7

Exercise 2 - Solution 8 Zip CodeAccept? abcdNo 12345Yes No Yes 1235No 54263Yes Yes Run Program … ClickClick

Exercise 2 – Report/Answers 9 Array ( [0] => Array ( [0] => Array ( [0] => [1] => 0 ) [1] => Array ( [0] => [1] => 11 ) [2] => Array ( [0] => [1] => 17 ) [3] => Array ( [0] => [1] => 27 ) [4] => Array ( [0] => [1] => 43 ) [5] => Array ( [0] => [1] => 49 ) ) [1] => Array ( [0] => [1] => [2] => [3] => Array ( [0] => [1] => 32 ) [4] => [5] => Array ( [0] => [1] => 54 ) )

10 Questions