08-08-2007, 04:15 AM
Basically I'm trying to eliminate potential problems when exporting user-entered text strings for use downstream of the macro (filenames, html, php, mysql etc.).
What is the best way to do both of these options:
A. Validate that a string contains only contains letters and numbers? (i.e. so I can throw up a message saying "Use only alphanumeric characters" when any special character/non-alphanumeric character exists in a text string)
B. Instead of forcing the user to re-enter/fix string, simply go ahead and replace invalid characters with an underscore like here:
but without having to list every undesirable character in the replacerx pattern. Essentially the equivalent expression that results in "for each character exists that is not alphanumeric, replace with '_' " (I should mention that I will not have to restore any of the characters removed at a later point).
Thanks in advance for any help!
Steve
What is the best way to do both of these options:
A. Validate that a string contains only contains letters and numbers? (i.e. so I can throw up a message saying "Use only alphanumeric characters" when any special character/non-alphanumeric character exists in a text string)
B. Instead of forcing the user to re-enter/fix string, simply go ahead and replace invalid characters with an underscore like here:
but without having to list every undesirable character in the replacerx pattern. Essentially the equivalent expression that results in "for each character exists that is not alphanumeric, replace with '_' " (I should mention that I will not have to restore any of the characters removed at a later point).
Thanks in advance for any help!
Steve