Re: Regex Question: All punct except...

2004-08-20 Thread Ben Doom
Alistair Davidson wrote:
> One solution I've used before in vaguely similar situations is to
> replace the / character with a placeholder, do the nice clean reg ex,
> then put the slashes back:
> but :
> -  you have to choose a placeholder that's never going to appear
> in your input string (I use something like "donkeyshiftingpignudger", or
> other such blather)

I ususally use the "bell" character (chr(7)) because it's not typable 
and doesn't show up in any of the predifined classes (IIRC).

--Ben
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




RE: Regex Question: All punct except...

2004-08-20 Thread Alistair Davidson
One solution I've used before in vaguely similar situations is to
replace the / character with a placeholder, do the nice clean reg ex,
then put the slashes back:

myString = replace( myString, "/", "PLACEHOLDER", "ALL" );

myString = REReplace( myString, "[[:punct:]]", "", "ALL" );

myString = Replace( myString, "PLACEHOLDER", "/" );

but :

-  it's going to be slower than doing it all in one regex

-  you have to choose a placeholder that's never going to appear
in your input string (I use something like "donkeyshiftingpignudger", or
other such blather)

-  it "feels" like a nasty kludge

so I only use it when I have to (i.e. when I just don't have time to get
the all-in-one reg ex working)
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Regex Question: All punct except...

2004-08-19 Thread Patricia Lee
Thanks for the repy and for the advice.  Not my strong suit, regex is.

-P

> I can't think of a clean way to use the punct class.
>
> However, I will state that writing out the chars you *do* want to
> replace in a class is going to run faster than what you have.  On the
> other hand, it's annoying to write.  :-)
>
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Regex Question: All punct except...

2004-08-19 Thread Ben Doom
I can't think of a clean way to use the punct class.

However, I will state that writing out the chars you *do* want to 
replace in a class is going to run faster than what you have.  On the 
other hand, it's annoying to write.  :-)

--Ben

Patricia Lee wrote:

> I want a CF regex to replace all punctuation except for the / character.
> 
> I made it work with the following:
> 
> [^/[:alpha:][:digit:][:space:]]
> 
> But I was wondering if there was a simpler way to write it with the
> [:punct:] class?
> 
>
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]