Being a Perl programmer also, this is one of the things that really
frustrates me about CF's regular expressions.
Okay, so back in the day, Allaire decided to go with POSIX-style character
classes. That still doesn't explain to me why you have to put the extra
square brackets in there, and it doesn't explain why I can't write:
[:digit:]{3}-?[:digit:]{4} to describe a US-style telephone number
without an area code. I work with three different software packages that
all support "regular expressions", but there's nothing "regular" about
them. They all use different notations, they all have quirks, and I still
have to look it up in order to remember which "regular" expression I'm
using.
Maybe I'm missing something, but I haven't been able to take my knowledge
of regexp that I learned from Perl and apply it to CF with any semblance of
consistency.
|------------------+------------------------------------------------------|
|Eric A. Laney |Happiness: |
|Systems Engineer |An agreeable sensation arising from contemplating the |
|LAN Optimization |misery of another. |
|Team | |
|Voice: | |
|813.978.4404 | |
|Pager: | |
|888.985.8519 | |
|------------------+------------------------------------------------------|
"Dain
Anderson" To: CF-Talk <[EMAIL PROTECTED]>
<DainAnderson@ cc:
nc.rr.com> Subject: Re: Regular Expression Help
07/27/2001
08:28 AM
Please respond
to cf-talk
John,
Your assumption is correct. The part that may have confused you originally
is that POSIX-style character classes (ie, [:punct:]) are surrounded by
brackets and colons, in addition to the bracket set that defines the entire
character class, such as [[:alpha:][:punct:][:cntrl:]] etc...
Numeric charcter classes are special in that you can use a hyphen for any
range of numbers, such as [0-9], [0-3], [3-7], etc. which emcompass every
number in that specific range.
Dain Anderson
Caretaker, CF Comet
http://www.cfcomet.com/
----- Original Message -----
From: "John Barleycorn" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, July 27, 2001 1:39 AM
Subject: Re: Regular Expression Help
> Dain, thank you very much. Is it safe to assume then that anything else i
> want to search for can be added by placing the definition inside another
> pair of brackets?
>
> REFindNoCase("[[:Alpha:][0-3][ ][:Punct:]]", myString)
> (added [0-3] and [ ] to find a space)
>
> thanks.
>
> >From: "Dain Anderson" <[EMAIL PROTECTED]>
> >Reply-To: [EMAIL PROTECTED]
> >To: CF-Talk <[EMAIL PROTECTED]>
> >Subject: Re: Regular Expression Help
> >Date: Thu, 26 Jul 2001 21:02:45 -0400
> >
> >John,
> >
> >You almost had it (too many brackets):
> >
> ><cfif REFindNoCase("[[:Alpha:][:Punct:]]", myString)>
> > Alpha characters or punctuation were found.
> ><cfelse>
> > No alpha characters or punctuation found.
> ></cfif>
> >
> >If you need to get the position of the first occurance of these
characters,
> >use subexpressions:
> >
> ><cfset mystring = "1234.ABCD">
> >
> ><!--- Use the 'returnsubexpressions' parameter to get the position --->
> ><cfset something = REFindNoCase("[[:Alpha:][:Punct:]]", myString, 1,
> >"True")>
> >
> ><cfif something.pos[1]>
> ><cfoutput>
> > Characters found at position: #something.pos[1]#<BR>
> ></cfoutput>
> ><cfelse>
> > No alpha characters or punctuation found.
> ></cfif>
> >
> >Dain Anderson
> >Caretaker, CF Comet
> >http://www.cfcomet.com/
> >
> >
> >
> >----- Original Message -----
> >From: "John Barleycorn" <[EMAIL PROTECTED]>
> >To: "CF-Talk" <[EMAIL PROTECTED]>
> >Sent: Thursday, July 26, 2001 6:42 PM
> >Subject: Regular Expression Help
> >
> >
> > > Hello, i'm having some trouble using regular expressions. i read the
> >book
> > > and looked up examples, but unfortunately, i can't seem to solve my
> >problem.
> > > i've written code that checks to see if there is either a letter or a
> > > punctuation mark in a string, but it's not returning results
properly.
> > > here's the code:
> > >
> > > <cfset something = REFindNoCase('[[:Alpha:]][[:Punct:]]', myString)>
> > >
> > > and my return value is always zero. can anyone tell me how this
should
> >be
> > > written so that i works? thanks for your help.
> > >
> > > oh, forgot one thing, i also need to check to see if there are any
> >spaces
> > > inside the string. that's something i also don't know how to do.
thanks
> >a
> > > lot.
> > >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists