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.

is there a better way to do this?

Old posts that have not been replied to for several years.
Locked
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

is there a better way to do this?

Post by droolin »

i have some code that works, but there has to be a better way to do this. Could anyone offer sugestions?????

Code: Select all

set namecheck [string map {":" "" "0" "" "1" "" "2" "" "3" "" "4" "" "5" "" "6" "" "7" "" "8" "" "9" ""} [lrange $text 5 end]]
That line of code looks like crap to me, is there a better way? regsub????

Any help is most appriceated.

droolin
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

regsub \[:0-9\]{1,} [lrange $text 5 e] "" namecheck
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

add -all switch to regsub

Code: Select all

regsub -all \[:0-9\]{1,} [lrange $text 5 e] "" namecheck 
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

thank you

Post by droolin »

Thank you, that worked great. Ya know, most of the time when i see something like that. I understand it. This one, I dont understand it all.

Code: Select all

regsub -all \[:0-9\]{1,} [lrange $text 5 e] "" namecheck 
1. why the back slash's? I dont see any escape characters? Or is that because of the enclosure of the search argument in the []'s?
2. What does the {1,} do? That one I have no idea on. Not a clue.

Thank you again, the help was very much appriceated.

droolin
Locked