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
Auf dieser Seite können Sie das Online-Video JavaScript Regular Expressions Part4 - JavaScript Tutorial 91 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer ChidresTechTutorials 27 Januar 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 863 Mal angesehen und es wurde von 27 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!