<! Body > <BODY> <!-{2,}.*?-{2,}> <! Start of page > <HTML> <! Start of head > <HEAD> <TITLE>My Title</TITLE> <! Page title > </HEAD> <! Body > <BODY> <!-{2,} matches the start of the comment, <! followed by two or more hyphens. .*? matches the comment body (not greedy). -{2,}> matches the end of the comment. Note This regular expression matches two or more hyphens and can thus be used to find CFML comments, too (which are identified by three hyphens). However, the pattern does not attempt to match the number of hyphens at the comment's start and close (potentially a useful enhancement in finding mismatched comments). JavaScript Comments Comments in JavaScript (and in other scripting languages, including ActionScript and other ECMA Script derivatives) are preceded by //. As in the previous example, being able to locate all comments in a page at once can be very useful. <SCRIPT LANGUAGE="JavaScript"> // Turn off fields used only by replace function hideReplaceFields() { document.getElementById('RegExReplace').disabled=true; document.getElementById('replaceheader').disabled=true; } // Turn on fields used only by replace function showReplaceFields() { document.getElementById('RegExReplace').disabled=false; document.getElementById('replaceheader').disabled=false; } //.* <SCRIPT LANGUAGE="JavaScript"> // Turn off fields used only by replace function hideReplaceFields() { document.getElementById('RegExReplace').disabled=true; document.getElementById('replaceheader').disabled=true; } // Turn on fields used only by replace function showReplaceFields() { document.getElementById('RegExReplace').disabled=false; document.getElementById('replaceheader').disabled=false; } This is a simple one; //.* matches // followed by the comment body. Note Unlike most regular expression implementations, in ColdFusion . matches new-line characters. As such, if you are using ColdFusion you will need to modify this pattern so that it uses a lazy quantifier (replacing .* with .*?). Credit Card Numbers Credit card numbers cannot be truly validated using regular expressions; final validation always requires some interaction with a credit card processing organization. However, regular expression validation can indeed be useful in trapping typos (like one digit too many or too few) before submitting any data anywhere. Note The patterns used here all assume that any embedded spaces or hyphens have been removed. This is generally a good practice to remove any nondigits from credit card numbers before performing any regular expression processing. All credit cards follow a basic numbering scheme—an opening digit sequence followed by a specified number of digits. We'll start with MasterCard. MasterCard: 5212345678901234 Visa 1: 4123456789012 Visa 2: 4123456789012345 Amex: 371234567890123 Discover: 601112345678901234 Diners Club: 38812345678901 5[1-5]\d{14} MasterCard: 5212345678901234 Visa 1: 4123456789012 Visa 2: 4123456789012345 Amex: 371234567890123 Discover: 601112345678901234 Diners Club: 38812345678901 All MasterCard numbers are 16 digits; the first digit is always 5, and the second digit is 1 through 5. 5[1-5] matches the first two digits; \d{14} matches the next 14 digits. Visa is a little trickier. MasterCard: 5212345678901234 Visa 1: 4123456789012 Visa 2: 4123456789012345 Amex: 371234567890123 Discover: 601112345678901234 Diners Club: 38812345678901 4\d{12}(\d{3})? MasterCard: 5212345678901234 Visa 1: 4123456789012 Visa 2: 4123456789012345 Amex: 371234567890123 Discover: 601112345678901234 Diners Club: 38812345678901