Javascript regular expression
Upcoming SlideShare
Loading in...5
×
 

Javascript regular expression

on

  • 377 views

 

Statistics

Views

Total Views
377
Views on SlideShare
377
Embed Views
0

Actions

Likes
0
Downloads
8
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Javascript regular expression Javascript regular expression Presentation Transcript

    • JavaScript Regular Expression
    • • A regular expression is an object that describes a pattern of characters. • regular expressions is used to perform patternmatching and search-and-replace on text.
    • Syntax for Regular Expression • Var pattern=/….Expression …/
    • Examples • Pattern for All lowercase letters var pattern=/[a-z]/ • Pattern for All Uppercase letters var pattern=/[A-Z]/ • Pattern for all letters var pattern=/[a-zA-Z]/ • Pattern for only digits var pattern=/[0-9]/
    • Examples • Pattern for age var pattern=/^d{1,2}$/ • Pattern for mobile number. var pattern=/^d{10}$/;
    • Metacharacter • A metacharacter is simply an alphabetical character preceded by a backslash that acts to give the combination a special meaning.
    • Validation email ID • Var pattern=/^w+([.-]?w+)*@w+([.]?w+)*(.w{2,3})+$/ Characters Description /../ all regular expression start with forward slash ^ w+ .- matches beginning of string matches one or more word char indicate next char is special matches . Or _ and end
    • • Characters ? or 1 time Description Matches previous char 0 ([.-]?w+)* matches 0 or more occurences of [.-]w+ @ matches @only (.w{2,3}) it matches . Followed by 2 or 3 word char
    • • Characters Description + indicates expression occur one or more times e.g. .com, co.us $ matches end of string