|
||
Regular ExpressionsBeginnerHow can I prevent users entering £ $ and , in a currency form field? Use this regular expression REReplace(YourCurrencyField, "[^0-9\.]+", "", "ALL") That will delete everything but decimals and numbers. How can I strip HTML from a variable? <cfset Field = ReReplace(Field, "<[^>]*>", "", "all")> Taken from Ben Forta's Advanced Web Application Construction Kit Regular Expressions are a quasi-language etc etc (!!!copy from chapter intro!!!) AdvancedHow can I check that only numbers and letters have been entered into a form field? This RE will match if anything but a letter or number is passed. <cfif REFind("[^a-zA-Z0-9]", YourStringVariable)>
What is the Regular Expression to validate an e-mail address? A special thanks to Erik Voldengen for this e-mail validation RegEx. It handles multiple top levels, checks for valid root domains, disallows double @@ and will ensure that the email address contains just "alphanumeric" characters. <cfset Email = "jon.doe@TopLevel.YourSite.com">
<cfif REFindNocase("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$", Email)>
Good address.
<cfelse>
Very, very bad.
</cfif>
Where can I find out more about Regular Expressions? http://www.houseoffusion.com/httpagent.ppt Also, consult the ColdFusion Studio help files. Check under Using ColdFusion Studio | 12 Testing and Maintaining Web Pages | Using Find and Replace. |
||
|
||