Regular Expressions Resource Area

Welcome to the Programmer's Heaven Regular Expressions resource area. Whether you have never used regexes before or if you're a guru, we have something useful for you here.

Tutorials

If you are new to regular expressions or want to learn more about them, you may want to check out our tutorial. We suggest that you open our regular expression testing tool in another window, so you can try out what you are learning.

Once you have a basic grounding in regular expressions, it's useful to know how to use them in the programming language you are working in. We have tutorials for the following languages/platforms: If you just need to brush up on your regex syntax or want an overview of what works in which implementations, our regex quick-reference is here to help.

Testing

Need to test whether a regex matches a string and see what it captures? Try out our powerful regex testing tool.

Regex Library

We have assembled a library of regexes that solve a lot of common problems in validation and extracting data. Start your search by selecting a category.

Under The Hood

You don't need to know the theoretical background of regular expressions and how you might go about implementing a regular expression engine, but if you're curious then check out this article.

About The Author

Jonathan Worthington works at Programmer's Heaven, hacking on code in a multitude of languages and writing numerous articles. He holds a degree in Computer Science from the University of Cambridge, England, and his main areas of interest are programming language design and semantics, compilers, virtual machines and type theory. He has worked in web development for a number of years and contributes to Parrot, the runtime for the next version of Perl and other dynamic languages. In his free time Jonathan loves to travel, especially to places with beautiful scenery where he can go walking.

  User Comments


Anonymous
(Not rated)
(Report as abusive)
new String("123")????
new String(<literal>) is a newbie mistake... just use the literal directly.
Anonymous

(Report as abusive)
the comment above is incorrect
It is true that declaring variables unnecessarily is a frequent newbie mistake. However, in this case, it is necessary to have a String object to operate on.

For example, if you don't put the string in var text here, you can't use the replace method on it:

var text = "abababab";
var altered = text.replace(/b/, 'a');

Would you write that as
var altered = "abababab".replace(/b/, 'a');

I think not.

However, I do think that there is a typo in the telephone number example. The string is placed into a variable named "phone", so the second line should probably be:
var lastfour = phone.match(/\d{4}$/);

instead of
var lastfour = text.match(/\d{4}$/);

which (probably inadvertently) references a variable named "text" which is used in adjacent examples.
  View all   Rate and comment this article




 
Printer friendly version of the Regex page



Advertisement



Free Magazine

Free Magazines
eWeek The essential technology information source for builders of e-business.... subscribe now

Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.