#28 Regular Expressions in JavaScript Part 1




What Is a Regular Expression?
A regular expression is a sequence of characters that forms a search pattern.
When you search for data in a text, you can use this search pattern to describe what you are searching for.
A regular expression can be a single character or a more complicated pattern.
Regular expressions can be used to perform all types of text search and text replace operations.
A regular expression in JS is an object that describes a pattern of characters.
The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on the text.
Video by – Tanmay Sakpal
Simple Snippets Channel link – https://www.youtube.com/simplesnippets

Original source


34 responses to “#28 Regular Expressions in JavaScript Part 1”

  1. How stupid is this
    Ur using var that's the first sign that Ur fresher
    People stop watching videos of idiots who are running YouTube channels just for money sake no experience AT all …
    Nd your is yukkk are you from village

  2. HI @Telusko ,i m watching ur videos regularly these are really good but i m facing an issue regarding alert function in visual code is "Function is not working" not for this video only but for previous videos also.I am coding in visual code only
    <html>

    <head>

    <title>Regular expression page</title>

    <script src='text/javascript'>

    /*this program related to show regular expression powerful pattern matching

    Regular expressions are case sensitive

    for testing regular expression use 'regex101' website

    regular expression in JS treating as object

    */

    function validate(){

    var uname=document.getElementById("uname").value;

    var regx=/F101/;

    if(regx.test(uname)){ //this is one way to use regular expression ,here test is used to check

    //the expression in regx is in textbox or not

    alert("valid employee name");

    }

    else{

    window. alert("invalid employee name");

    document.getElementById("lbl") .style.visibility="visible" ;

    }

    }

    </script>

    </head>

    <body>

    <form >

    <input id="uname" type="text" placeholder="employee id"/><br>

    <label id="lbl" style="color :brown; visibility:hidden "><br>Invalid Employee name</label><br>

    <button type="submit" onclick="validate();">submit</button>

    </form>

    </body>

    </html>
    please help to resolve this issue

Leave a Reply