I agree that the * (0 or more) should be avoided unless needed but in this
case I felt it was. There may or may not be a space. There may be more than
one space. There may be a space character being seen as a space (like a
tab).
Because we don't know if a space will actually exist, the * is needed. The
+? (1 or more but as few as needed) assumes that at least one space exists.

As a rule I don't over-worry about using * when it's used with a \s (space)
unless I really have to.

On Tue, Nov 23, 2010 at 12:20 AM, andy matthews <li...@commadelimited.com>wrote:

>
> For future reference you should avoid using * where possible as it can
> easily lead to overmatching. Even using + would be better although both +
> and * alone are greedy matches. An even better solution would be to use a
> lazy match like so:
>
> \)\s+?\)
>
> The ? following the + tells the regex engine to match as little as
> possible.
>
>
>
> andy
>
> -----Original Message-----
> From: Rick Colman [mailto:rcol...@cox.net]
> Sent: Monday, November 22, 2010 9:59 PM
> To: cf-talk
> Subject: Re: REGEX hell
>
>
> This worked!! TNX.
>
> On 11/22/2010 6:04 PM, Michael Dinowitz wrote:
> > Are you sure it's a space and not 2 spaces? Or a tab? Try using \s* to
> > indicate that there may be one or more space characters.
> >
> > \)\s*\)
> >
> > <cfset cleandata2 = REReplaceNoCase(cleandata1, '\)\s*\)', ')', 'all')>
> >
> > On Mon, Nov 22, 2010 at 8:48 PM, Rick Colman<rcol...@cox.net>  wrote:
> >
> >> I am trying to replace two trailing parens )) with a single paren.
> >>
> >> here is a sample string:
> >>
> >> (K AAA) (N AAC) (E GAA) )
> >>
> >> looks like there is a space in between the two )), so I tried:
> >>
> >> <cfset cleandata2 = #REReplaceNoCase( cleandata1,'\)\ \)',')','all')#>
> >>
> >> but this is not working.
> >>
> >> Any ideas as two what is wrong greatly appreciated.
> >>
> >>
> >>
> >
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339446
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to