This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

RegSub question

Old posts that have not been replied to for several years.
Locked
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

RegSub question

Post by stammer »

Hi all,

i have string like this :

asfgghgfh45453*)_()([]{}!@#%^^%+-^#$#@35fsggdfg34534ASDEd45

my question is how to remove from it all except
alphabet characters --> a-z, A-Z

out string have to look like this :

asfgghgfhfsggdfgASDEd

Thanks alot.

P.S. Sorry for my bad English I'm from Bulgaria
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

take out an ASCII table and put just all ranges of that chars you don't like within [] braces like [\000-\377].
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Code: Select all

regsub -all -nocase {[^a-z]} $string {} cleanstring
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Hmm, I somehow missread that [^...] thing in the manual, very intresting indeed :). in his example a much better solution :D.
For example, assume the collating sequence includes a ch multi-character collating element. Then the RE [[.ch.]]*c (zero or more ch's followed by c) matches the first five characters of `chchcc'. Also, the RE [^c]b matches all of `chb' (because [^c] matches the multi-character ch).
confused me and made me ignore that:
If the list begins with `^', it matches any single character (but see below) not from the rest of the list.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

Post by stammer »

Thanks alot to all :)

everything working ok...
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

Code: Select all


      regsub -all -- {[^A-z]} $text "" cleanstring

I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Dedan wrote:

Code: Select all


      regsub -all -- {[^A-z]} $text "" cleanstring

whats the sense of this? if you had looked at the posted ASCII table, you would know, that "A-z" and -nocase "a-z" are NOT the same.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Locked