?
Solved

I need some more regular expression help

Posted on 2003-02-27
3
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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