Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Tools for writing regular expressions

Suggested Videos
Part 45 - JavaScript mouse events
Part 46 - JavaScript popup window
Part 47 - Using regular expressions in JavaScript



In this video we will discuss the basics of regular expressions and then look at some of the tools available to learn, write and test regular expressions.



Basics of Regular Expressions : 

Find the word expression in a given string. This will also match with the word expressions.
expression

To find the word "expression" as a whole word, include \b on either sides of the word expression
\bexpression\b

\d indicates to find a digit. To find a 5 digit number we could use the following
\b\d\d\d\d\d\b

We can avoid the repetition of \d by using curly braces as shown below. \d{5} means repeat \d 5 times.
\b\d{5}\b

The above example can also be rewritten as shown below.
\b[0-9]{5}\b

Find all the words with exactly 5 letters
\b[a-zA-Z]{5}\b

Brackets are used to find a range of characters
[a-z] - Find any of the characters between the brackets
[0-9] - Find any of the digits between the brackets. This is equivalent to \d
(a|b) - Find any of the characters a or b

The page at the following link explains the basics of regular expressions.
https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions

Expresso is one of the free tools available. Here is the link to download.
http://www.ultrapico.com/ExpressoDownload.htm

Regular Expression Library
http://regexlib.com

JavaScript tutorial

1 comment:

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.