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

Old posts that have not been replied to for several years.
Locked
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

regsub

Post by Dedan »

would you please help me,
i have a 300 line script that has only 1 bug left.
i have been trying for days to get this 1 bug out.
the bug has to do with charcters. : = < > ¶ etc.

i need a regsub command.
I have read the manuals and tried until i have given up.
please help.

i want a regsub command that replaces ALL charcters with "x"
except a-z , A-Z and 0-9


regsub -all -- {} $text "x" text

regsub -all -- {![[:alnum:]]} $text "x" text
regsub -all -- {![A-Za-z0-9]} $text "x" text




thanks
I once was an intelligent young man, now i am old and i can not remember who i was.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Re: regsub

Post by egghead »

Dedan wrote: i want a regsub command that replaces ALL charcters with "x"
except a-z , A-Z and 0-9

regsub -all -- {![A-Za-z0-9]} $text "x" text

thanks
In regular expressions:
[a-z] : match range of characters
[^a-z] : match characters not in range
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

thanks egghead ... i kept thinking
"^" ment "only the first letter" but that
is when it outside the brackets ... thanks.

finial code

regsub -all -- {[^ A-Za-z0-9]} $text "x" text

thanks again egghead :D
I once was an intelligent young man, now i am old and i can not remember who i was.
Locked