Free Web Development Online Tutorials, Learn to Code
Learn JavaScript, Free JavaScript Tutorial for Beginners, Interactive JavaScript Examples

Javascript Regular Expresssion

Regular expressions is a powerful way of doing search and replace in any strings, a regular expression describes a pattern of characters.

Patterns and flags

Slashes "/" indicate JavaScript that we are starting a regular expression, just like quotes for strings.

var str = "WebTrainingRoom.Com is a eLearning Platform";
var wtrRegExp=/WebTrainingRoom/i

Modifier Description
i Perform case-insensitive matching
g Perform a global match (find all matches in given string rather than stopping after first match)
m Perform multiline matching
Bracket is used for finding a range of characters:
Expression Description
[xyz] Find any character between the brackets
[^xyz] Find any character NOT between the brackets
[0-9] Find any character between the brackets (any digit)
[^0-9] Find any character NOT between the brackets (any non-digit)
(a|b) Find any of the alternatives specified
Methods of RegExp and String

Javascript Regular Expresssion

javascript Interview Questions Answers

JavaScript Examples | JavaScript Online Course