CIS 111 Lecture Notes - Lecture 5: Whitespace Character, Newline, 7 Up

41 views3 pages
Regular Expressions (Wk 6)
What We Will Cover in Class
o RegExp
o Window.addEventListener
JavaScript Objects
Type
What it Does
Array
helps store, retrieve, and manipulate collection of data
Boolean
acts as wrapper around Boolean primitive; still very much in love w/ true / false
Date
allows you to more easily represent and work w/ dates
Function
allows you to invoke some code among other esoteric things
Math
nerdy one in group that helps you better work w/ numbers
Number
acts as wrapper around number primitive
RegExp
provides a lot of functionality for matching patterns in text
String
acts as wrapper around string primitive
Learning Regular Expressions (RegExp)
o Regular expressions are a way to describe patterns in string data
o Form small, separate language that is part of JavaScript and other languages
o RegExp patterns are used with exec and test methods, and with match, replace,
search, and split String methods
Creating RegExp
o Type of object
Can be either constructed with RegExp constructor or written as literal value
by enclosing pattern in forward slash (/) characters
let e=e RegEpjaa;
let re2=/java/;
e.testjaasipt;
Testing for Matches
o RegExp objects have a number of methods. Simplest is test.
If you pass it a string, it will return a Boolean telling you whether the string
contains a match of the pattern in the expression
Let re2=/java/;
Re.testjaasipt; //true
Re.testJaasipt; //false
/a/.testade; //true
/a/.testade; //false
Matching set of Characters
//following expression matches all strings that contain a digit
let pattern=/[0123456789]/;
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents