Notes for You:: JavaScript Regular Expressions Part4 - JavaScript Tutorial 91
JavaScript RegExp Starts and Ends with
Sequence of characters enclosed in between pair of forward slash symbols indicates a regular expression in JavaScript
Syntax for defining a variable of type regular expression is:
var variableName = /search pattern/ [flags] ;
Ex: validating a phone number
var pattern = / ^[0-9]{10}$ /;
Begins with & Ends with Meta characters:
are used to test whether a string begins with a specific pattern and/or ends with specific pattern
Ex:
^a
indicates whether a string begins with a character
a$
indicates whether a string ends with a character
Example Code:
document.write( /^A/.test("Agent007 is the best agent") ); // true
document.write( /^A/.test("Bgent007 is the best agent") ); // false
document.write( /^Agent/.test("Agent007 is the best agent") ); // true
document.write( /^Agent007/.test("Agent007 is the best agent") ); // true
document.write( /^Agent007/.test("Agent008 is the best agent") ); // false
document.write( /7$/.test("I am Agent007") ); // true
document.write( /7$/.test("I am Agent008") ); // false
document.write( /Agent007$/.test("I am Agent007") ); // true
document.write( /Agent007$/.test("I am Agent008") ); // false
document.write( /^Agent007$/.test("Agent007") ); // true
document.write( /^Agent007$/.test("Agen-t007") ); // false
=========================================
Follow the link for next video:
JavaScript Tutorial 92 - Quantifiers in Regular Expression JavaScript
• JavaScript Regular Expressions Part5 ...
Follow the link for previous video:
JavaScript Tutorial 90 - Regular Expression Meta Characters in JavaScript
• JavaScript Regular Expressions Part3 ...
=========================================
JavaScript Tutorials Playlist:-
• JavaScript Tutorials
=========================================
Watch My Other Useful Tutorials:-
jQuery Tutorials Playlist:-
• jQuery Tutorials
jQuery UI Tutorials Playlist:-
• jQuery UI Tutorials
Bootstrap Tutorials Playlist:-
• Bootstrap4 Tutorials
=========================================
► Subscribe to our YouTube channel:
/ chidrestechtutorials
► Visit our Website:
https://www.chidrestechtutorials.com
=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial
On this page of the site you can watch the video online JavaScript Regular Expressions Part4 - JavaScript Tutorial 91 with a duration of hours minute second in good quality, which was uploaded by the user ChidresTechTutorials 27 January 2022, share the link with friends and acquaintances, this video has already been watched 863 times on youtube and it was liked by 27 viewers. Enjoy your viewing!