Hi, 

i have a function that simply tries to match a value that is being passed in 
matches a title. the function is currently as follows:

<cffunction name="isValidTitle" hint="is passed a value, and checks to ensure 
that it is either M or F, and either returns true or the error">
  <cfargument name="value" type="any" required="true">

  <!--- declare the regaulr expression set --->
  <cfset var titleRegEx = "\b(Dr|Prof|Mr|Mrs|Ms|Miss)\b"> <!--- allowable --->
  <cfset var regExMatchArray = rematchnocase(titleRegEx,value)>

  <!--- looks through the string to find m or f, if everything is ok then it 
returns a number 1 greater than the length of the value, else it returns the 
position of the character in the value that it fails on --->
  <cfif arraylen(regExMatchArray) eq 0 or len(regExMatchArray[1]) neq 
len(value)> 
    <cfreturn "Invalid Title: #value# (Valid Title: Dr,Prof,Mr,Mrs,Ms,Miss)">
  <cfelse>
    <cfreturn true>
  </cfif>

</cffunction>

i have been looking at various regex tutorials about options, and also looked 
the the very useful regex tutorial site: 
http://www.regular-expressions.info/alternation.html

but the problem i am having is that it will match any pattern including the 
pipe, so if i type in Dr| then it will return true. however i want it to return 
false, i cannot seem to find anywhere that tells me how to deal with this

i would appreciate any feedback

thanks

richard 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:313952
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to