0
JavaScript Regular
Expression
• A regular expression is an object that describes a
pattern of characters.

• regular expressions is used to perform patt...
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]/
•...
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
combinat...
Validation email ID
• Var pattern=/^w+([.-]?w+)*@w+([.]?w+)*(.w{2,3})+$/

Characters

Description

/../
all regular expres...
• Characters
?
or 1 time

Description
Matches previous char 0

([.-]?w+)*
matches 0 or more
occurences of [.-]w+
@

matche...
• Characters

Description

+

indicates expression occur
one or more times e.g.
.com, co.us

$

matches end of string
Javascript regular expression
Javascript regular expression
Javascript regular expression
Javascript regular expression
Javascript regular expression
Upcoming SlideShare
Loading in...5
×

Javascript regular expression

256

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
256
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Javascript regular expression"

  1. 1. JavaScript Regular Expression
  2. 2. • 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.
  3. 3. Syntax for Regular Expression • Var pattern=/….Expression …/
  4. 4. 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]/
  5. 5. Examples • Pattern for age var pattern=/^d{1,2}$/ • Pattern for mobile number. var pattern=/^d{10}$/;
  6. 6. Metacharacter • A metacharacter is simply an alphabetical character preceded by a backslash that acts to give the combination a special meaning.
  7. 7. 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
  8. 8. • 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
  9. 9. • Characters Description + indicates expression occur one or more times e.g. .com, co.us $ matches end of string
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×