EECS 1012 Lecture Notes - Lecture 11: Regular Expression, Empty String, Pattern Matching

201 views3 pages
Verified Note

Document Summary

Lecture 11- javascript and forms (final lecture for 2018 because php lecture won"t be on exam) Javascript considers all expressions to be true, except the following: 0 (zero is considered false, but not "0") Nan (this happens in some math, e. g. 0/0;) false (of course-false is false) We have seen how to use alert to output messages. For debugging, you can also use the console object. Example: function myfunction() { var num1 = 5; if (num1==5) { console. log("num1 is equal to" + num1); A regular expression is a text string that defines a character pattern. You create a regular expression in javascript using the command var re = This syntax for creating regular expressions is sometimes referred to as a regular expression literal. We can use the regular expression variable re. test("some string") The method test() return true if the string contains the pattern. A string comparison has to be exact. Patterns can include characters (or character ranges) specified between brackets.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents