How to get rid of non - alpha-numeric characters? (1 Viewer)

vbaInet

AWF VIP
Local time
Today, 13:43
Joined
Jan 22, 2010
Messages
26,374
Hi Leigh,

Good to see you're in on this too :)

The first part of your regex removes the brackets and its contents but what the OP is after is for it to also removing any extra spaces left over after the removal.

So this:
" (123) The (b)big brown(wn) fox jumped (jumped) o(344)ver the lazy dog (123)"

... becomes this:
"The big brown fox jumped over the lazy dog"
 

LPurvis

AWF VIP
Local time
Today, 13:43
Joined
Jun 16, 2008
Messages
1,269
Heh, I wouldn't exactly say I'm getting in on it. (Such time elludes me at the moment.)
Just thought I'd throw out something I'd previously done. I'll leave you to your lengthy expressions. It looks like you've got a solution anyway...

Cheers.
 

vbaInet

AWF VIP
Local time
Today, 13:43
Joined
Jan 22, 2010
Messages
26,374
The shorter the better, so if you've got a better regex please share :) It would be nice to know. Any thoughts?
 

LPurvis

AWF VIP
Local time
Today, 13:43
Joined
Jun 16, 2008
Messages
1,269
I'd agree - the shorter the better. Hence why I'd probably view returning multiple spaces as a result of the Reg Exp replace, and so something to be subsequently handled.
(Otherwise the expression becomes more and more unwieldy - as you've found. ;-)

For example (and again I don't know if this has already been set aside as a consideration - but then I don't see why it should be), consider the possibility that there are already multiple spaces in the original text. Do you then include that in the expression? How many do you cater for?

Away from Reg Exp, there are common methods (and even one very cool way) of reducing multiple spaces down to one.

Of course, I completely understand the challenge of finding an all encompassing expression... I've got lost in many personal challenge searches in the past. (Some resulted in articles!) I'm suppose I'm in more of a "get solutions, get paid" mentality at the moment. lol.

Cheers.
 

Users who are viewing this thread

Top Bottom