LING 408/508: Programming for Linguists Lecture 14 October 19 th.

Slides:



Advertisements
Similar presentations
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
Advertisements

LING 408/508: Programming for Linguists Lecture 13 October 7 th.
25-Jun-15 JavaScript Language Fundamentals II. 2 Exception handling, I Exception handling in JavaScript is almost the same as in Java throw expression.
Tutorial 14 Working with Forms and Regular Expressions.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
Learning Ruby - 6 Regular Expressions. Ruby's Regex Technology Specifying what you are after using a terse, compact syntax Very useful when working with.
Adding First, you need to know… Associative Property of Addition When: (a + b) + c = a + (b + c) Commutative Property of Addition When: a + b= b + a.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Read Lecturer.
slides created by Marty Stepp
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Tutorial 14 Working with Forms and Regular Expressions.
Pattern matching with regular expressions A common file processing requirement is to match strings within the file to a standard form, e.g. address.
Modern JavaScript Develop And Design Instructor’s Notes Chapter 10 – Working with Forms Modern JavaScript Design And Develop Copyright © 2012 by Larry.
JavaScript Lecture 6 Rachel A Ober
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Arrays – What is it? – Creation – Changing the contents Functions – What is it? – Syntax – How they work – Anonymous functions A quick lesson in Objects.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 4: 8/30.
More Events and Validation CS Page/window events CS380 2.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 3.
Objects.  Java Script is an OOP Language  So it allows you to make your own objects and make your own variable types  I will not be going over how.
RegExp. Regular Expression A regular expression is a certain way to describe a pattern of characters. Pattern-matching or keyword search. Regular expressions.
Regular Expressions Regular expressions are a language for string patterns. RegEx is integral to many programming languages:  Perl  Python  Javascript.
Yet more on XSLT. Regular expression handling in EXSLT We saw that the EXSLT extensions are divided into a group of modules, each of which has its own.
Programming in Perl regular expressions and m,s operators Peter Verhás January 2002.
CS412/413 Introduction to Compilers Radu Rugina Lecture 4: Lexical Analyzers 28 Jan 02.
Regular Expressions. 2 3 Using Regular Expressions Regular expressions give you much more power to handle strings in a script. They allow you to form.
Post-Module JavaScript BTM 395: Internet Programming.
Regular Expressions in PHP. Supported RE’s The most important set of regex functions start with preg. These functions are a PHP wrapper around the PCRE.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming regular expressions.
JavaScript, Part 2 Instructor: Charles Moen CSCI/CINF 4230.
12. Regular Expressions. 2 Motto: I don't play accurately-any one can play accurately- but I play with wonderful expression. As far as the piano is concerned,
Javascript’s RegExp. RegExp object Javascript has an Object which compiles Regular Expressions into a Finite State Machine The F.S.M. is internal, and.
CS346 Regular Expressions1 Pattern Matching Regular Expression.
Prototypal Inheritance. Can We Do Inheritance Without Classes? How do we share behaviour across objects.
Copyright © Curt Hill Regular Expressions Providing a Search Pattern.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
1 Lecture 9 Shell Programming – Command substitution Regular expressions and grep Use of exit, for loop and expr commands COP 3353 Introduction to UNIX.
1 Validating user input is the bane of every software developer’s existence. When you are developing cross-browser web applications (IE4+ and NS4+) this.
Regular Expressions Pattern and String Matching in Text.
10 – Java Script (3) Informatics Department Parahyangan Catholic University.
JavaScript Assignment Statements Expressions Global Functions CST 200 JavaScript.
LING 408/508: Programming for Linguists
LING 408/508: Programming for Linguists Lecture 15 October 21 th.
Validation using Regular Expressions. Regular Expression Instead of asking if user input has some particular value, sometimes you want to know if it follows.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
REGULAR EXPRESSIONS 1 DAY 6 - 9/08/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
INT222 – Internet Fundamentals Week 11: RegExp Object and HTML5 Form Validation 1.
Regular Expressions /^Hel{2}o\s*World\n$/ SoftUni Team Technical Trainers Software University
Unit 10-JavaScript Functions Instructor: Brent Presley.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
MTA EXAM HTML5 Application Development Fundamentals.
Drop-down box. Objectives Learn the HTML syntax of a drop-down list javascript properties of a list/menu: length options selectedIndex The location sub-object.
An Introduction to Regular Expressions Specifying a Pattern that a String must meet.
Lecture 10 Closure Properties of Regular Languages Topics: Extended RegExpr Thompson Construction Test 1 Post Mortem October 1, 2008 CSCE 355 Foundations.
-Joseph Beberman *Some slides are inspired by a PowerPoint presentation used by professor Seikyung Jung, which was derived from Charlie Wiseman.
OVERVIEW OF CLIENT-SIDE SCRIPTING
Regular Expressions In Javascript cosc What Do They Do? Does pattern matching on text We use the term “string” to indicate the text that the regular.
SEEM4570 Tutorial 05: JavaScript as OOP
JavaScript Selection Statement Creating Array
LING 408/508: Computational Techniques for Linguists
Functions, Regular expressions and Events
i206: Lecture 19: Regular Expressions, cont.
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
Matcher functions boolean find() Attempts to find the next subsequence of the input sequence that matches the pattern. boolean lookingAt() Attempts to.
Validation using Regular Expressions
JavaScript Session III
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

LING 408/508: Programming for Linguists Lecture 14 October 19 th

Last Time Added bells and whistles to the BMI calculator: –

Javascript regular expressions Let's write our own browser-based tester to help you learn regular expressions: form

Javascript regular expressions Let's write our own browser-based tester to help you learn regular expressions: What Javascript provides: RegEx object –var re = new RegEx(string, flags) –var re = /[A-Z]([a-z])*/gi (g= global; i=ignore case) Methods: –var a = string.match(re) returns an array [entire match,...submatches…] –var a = regex.exec(string) returns an array – different behaviors (under global flag) optional

Javascript Regexp Tester String: Regex: Global match (g): document.getElementsByTagName("form")[0].re.value = "Mr\. ([A-Z][a-z]*)"

Javascript Regexp Tester function f(e) { var o = document.getElementById("output"); o.innerHTML = ""; var re_s = e.form.re.value; var s = e.form.str.value; if (re_s != "") { var flag_s = ""; if (e.form.g.checked) { flag_s += "g" } var regex = new RegExp(re_s,flag_s); if (e.form.g.checked) { var a; while (a = regex.exec(s)) { o.innerHTML += a.toString() + " " } } else{ o.innerHTML = s.match(regex).toString() } } }

Javascript Regexp Tester Let's try the code: – 15/re-test.html 15/re-test.html Mr. ([A-Z][a-z]*) Mr\. ([A-Z][a-z]*)

Javascript Regexp Tester Useful property – regex.lastIndex

Regular expression syntax

Regular expression syntax

Replace We'll also need the method replace(): var regex = new RegExp(re_s,flag_s); modified_string = string.replace(regex,replacement) – replacement string can contain $n – (n = group number) developer.mozilla.org