JavaScript Regular Expressions Part4 - JavaScript Tutorial 91

Pubblicato il: 27 gennaio 2022
sul canale di: ChidresTechTutorials
863
27

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


In questa pagina del sito puoi guardare il video online JavaScript Regular Expressions Part4 - JavaScript Tutorial 91 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato ChidresTechTutorials 27 gennaio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 863 volte e gli è piaciuto 27 spettatori. Buona visione!