Forum OpenACS Q&A: need regexp help: remove spaces and "&"

Postgresql has a nice translate command:
select translate(first_names,' ','_') from users where...

This means that the database has 'Bob Francis' and translates it to 'Bob_Francis' I want to do this in TCL because it is not yet in the database, it's on a form...

TCL: Take first_names and add to last_name to use as an all lower case screen name. Here are the examples that I want to account for along with a few extras... lower case, replace & with and, remove ' and all those @#$%&* characters!

Bob & Jean OConnor Jones
converts to
bobandjean_oconnor_jones

Bob Francis O'Connor
converts to
bob_francis_oconnor

My head hurts when I do regexp's and I've not found a good set of examples to work from.

Thankx-in-advance for help
-Bob

Assuming you are running nsd8x, you don't even need regular expressions. Using [string map] is easier on the brain, and should execute faster too:
% set text "Bob & Jean O'Connor Jones"
Bob & Jean OConnor Jones
% string map [list " & " and " " _ ' ""] [string tolower $text]
bobandjean_oconnor_jones
Collapse
Posted by Bob OConnor on
Woopie!, Easy! That doesn't hurt at all.
THANK YOU Michael.

-Bob