Re: REGEX hell

2010-11-25 Thread denstar

On Thu, Nov 25, 2010 at 10:48 AM, Peter Boughton wrote:
>
> To be clear, CF uses the Apache ORO library, which is different to both Perl 
> and Java Regex.

I've found the QuickREx Eclipse plugin *invaluable* for regular expression work.

It supports several different regex engines, has "libraries" of
regexes... It's fantastic!

:Den

-- 
The most important part of education is proper training in the nursery.
Plato

~|
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:339537
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-25 Thread Peter Boughton

To be clear, CF uses the Apache ORO library, which is different to both Perl 
and Java Regex. 

~|
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:339536
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-25 Thread Peter Boughton

In this situation, there is no real difference between lazy or greedy - because 
the quantified item is mutually exclusive with the next characters - i.e. "\s+" 
cannot match "\)" - so it will always consume to the end of the whitespace.

It is better to not assume lazy or greedy as a 'default' and always decide 
which one makes sense for the current scenario. 

~|
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:339535
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-25 Thread Charlie Griefer

... since we're throwing out recommendations for our favorite "so glad this
exists because of how badly I suck at reg ex" apps, I've found
http://gskinner.com/RegExr/desktop/ to be a -very- valuable tool.

On Thu, Nov 25, 2010 at 8:56 AM, Dave Merrill  wrote:

>
> Be a little careful, Regex Coach works with perl regex syntax; cf
> needs java syntax usually, with some differences.
>
> I can't recommend Regex Buddy highly enough. It's not free, but it's
> really quite excellent, supports a variety of different flavors.
>
> Dave
>
>
> On Thu, Nov 25, 2010 at 10:17 AM, Jerry Barnes 
> wrote:
> >
> > Regex that is useful but unfortunately, my skills are pretty weak in that
> > area.
> >
> > I use an application named "The Regex Coach' to build my code.  It has a
> > place to put the string you are trying to match and another place to put
> > your regex code.  As you modify the regex code, it highlights how much of
> > the string matches.
> >
> > The program is free with the option of donating via paypal to the creator
> if
> > you like it.
> >
> >
> >
> > J
> >
> > -
> >
> > No man's life, liberty, or property is safe while the legislature is in
> > session. - Mark Twain
> >
> >
> >
>
> 

~|
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:339533
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-25 Thread Dave Merrill

Be a little careful, Regex Coach works with perl regex syntax; cf
needs java syntax usually, with some differences.

I can't recommend Regex Buddy highly enough. It's not free, but it's
really quite excellent, supports a variety of different flavors.

Dave


On Thu, Nov 25, 2010 at 10:17 AM, Jerry Barnes  wrote:
>
> Regex that is useful but unfortunately, my skills are pretty weak in that
> area.
>
> I use an application named "The Regex Coach' to build my code.  It has a
> place to put the string you are trying to match and another place to put
> your regex code.  As you modify the regex code, it highlights how much of
> the string matches.
>
> The program is free with the option of donating via paypal to the creator if
> you like it.
>
>
>
> J
>
> -
>
> No man's life, liberty, or property is safe while the legislature is in
> session. - Mark Twain
>
>
> 

~|
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:339532
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-25 Thread Jerry Barnes

Regex that is useful but unfortunately, my skills are pretty weak in that
area.

I use an application named "The Regex Coach' to build my code.  It has a
place to put the string you are trying to match and another place to put
your regex code.  As you modify the regex code, it highlights how much of
the string matches.

The program is free with the option of donating via paypal to the creator if
you like it.



J

-

No man's life, liberty, or property is safe while the legislature is in
session. - Mark Twain


~|
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:339530
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-22 Thread Michael Dinowitz

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 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*\)
> >
> > 
> >
> > On Mon, Nov 22, 2010 at 8:48 PM, Rick Colman  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:
> >>
> >> 
> >>
> >> 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


RE: REGEX hell

2010-11-22 Thread andy matthews

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*\)
>
> 
>
> On Mon, Nov 22, 2010 at 8:48 PM, Rick Colman  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:
>>
>> 
>>
>> 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:339445
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-22 Thread Rick Colman

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*\)
>
> 
>
> On Mon, Nov 22, 2010 at 8:48 PM, Rick Colman  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:
>>
>> 
>>
>> 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:339444
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-22 Thread Michael Dinowitz

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*\)



On Mon, Nov 22, 2010 at 8:48 PM, Rick Colman  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:
>
> 
>
> 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:339443
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: REGEX hell

2010-11-22 Thread Jerry Johnson

no need to escape the space char with a slash.

are you sure it is only 1 space, and are you sure it is a space char
(chr(32))?

If so, remove the slash in front of the space, and it should work.

also, pet peeve, no need for the ## around the function. Works either way,
though, so ignore if you prefer.

Jerry Milo Johnson

On Mon, Nov 22, 2010 at 8:48 PM, Rick Colman  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:
>
> 
>
> 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:339442
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


REGEX hell

2010-11-22 Thread Rick Colman

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:



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:339441
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm