Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

I need some more regular expression help

Posted on 2003-02-27
3
Medium Priority
?
193 Views
Last Modified: 2013-12-24
I'm having an issue creating a rule that detects if a word contains invalid characters. The word is validated through a form field. I do not want to use javascript. What I have so far is:

<cfelseif NOT REFindNoCase ('[a-z0-9-]',#form.base#)>
<cfoutput>Word contains invalid characters</cfoutput>

This code works great if the word I put in the form field is "@#$%@$#%" but if the word contains a-z or 0-9 AND invalid characters, "word@#$here" it doesn't give the error. The only characters I want to allow are a-z,0-9 and hyphens. Please help. Thank you.
0
Comment
Question by:fozzynet
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
weeezl earned 300 total points
ID: 8036672
Try this:

<cfelseif NOT REFindNoCase ('^[a-z0-9-]+$',#form.base#)>
<cfoutput>Word contains invalid characters</cfoutput>

0
 
LVL 2

Expert Comment

by:weeezl
ID: 8036761
This basically tells it to search from the beginning of the string to the end of the string looking for all matches.

If you want to learn about the functions, there's a good tutorial here:

http://etext.lib.virginia.edu/helpsheets/regex.html
0
 

Author Comment

by:fozzynet
ID: 8036806
This worked absolutely great. Thank you so much.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question