<script language="javascript">
// our string that we are going to operate on
var inputstr="this is my long test string with the word long in it, hope that the Regular Expression does not take too LONG.";
// an empty string to hold the result
var outputstr="";
// our Regular Expression
var regex=/long/gi;
// run the Regular Expression to replace any match to our Regular Expression with the word short.
outputstr=inputstr.replace(regex,"short");
// popup the string which should be
//"this is my short test string with the word short in it, hope that the Regular Expression does not take too short."
alert(outputstr);
</script>
<script language="javascript">
// our string that we are going to operate on
var inputstr="A1234";
// our Regular Expression
var regex=/^[A-Z]\d{4}$/g;
// do the comparison, if we have a match
if (regex.test(inputstr))
{
alert("Matches");
}
else
{
alert("Does not match");
}
</script>
This concludes this introduction to Regular Expressions, the conclusion contains links to futher reading on the subject both on the internet as well as some books.