Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need REFindNoCase Help

New Here ,
Aug 24, 2006 Aug 24, 2006
I've been tasked with creating a simple validation for Canadian zip codes. The idea is that the first character of the zip code being entered need to contain one of the following letters:

ABCEGHJKLMNPRSTVXY

They don't necessarily have to be capatilzed.

I'm not good at regular expressions at all, so needless to say I'm having a heck of a time trying to make this work. It seems easy enough; can anyone help me figure out how to do this?

Josh
TOPICS
Advanced techniques
414
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 24, 2006 Aug 24, 2006
See code below
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 24, 2006 Aug 24, 2006
<CFSET foo = "R3B 3L7">
<CFIF REFindNoCase("[ABCEGHJKLMNPRSTVXY]", foo)>
Found it
<CFELSE>
Didn't find it
</CFIF>

I believe the addition of a carrot [^] will specify that the found
letter must be at the beginning of the string, not anywhere in the string.

<CFSET foo = "R3B 3L7">
<CFIF REFindNoCase("^[ABCEGHJKLMNPRSTVXY]", foo)>
Found it
<CFELSE>
Didn't find it
</CFIF>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 24, 2006 Aug 24, 2006
LATEST
Ian is correct. And while looking into this, I came across the following in Ben Forta's excellent book Regular Expressions in 10 Minutes - finding Canadian postal codes in an address line.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 24, 2006 Aug 24, 2006
Thanks, guys. I got it to work. It wasn't quite as simple as that because of another condition I forgot about, but it's working now.

Josh
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources