Since you have not shown the code in question, I can only guess as to your intentions. As tye mentioned, if you provide us with the code in question, we can comment on it.
On the off chance that this code is being used for taint checking, please discard it as what you describe is very dangerous from a security standpoint. When checking a user's input, it is much safer to specify what you will allow, as opposed to specifying what you won't allow. The former is often too restrictive, but safe; it can be loosened up as need arises. The latter follows the Microsoft model: make it easy to use, but plug security holes after people are burned.
A classic case is people checking to ensure that the pipe character "|" is not in input, while being unaware that some Unix variants use a caret "^" for redirection instead of a pipe. Who thinks of a caret as being a dangerous character?
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats. | [reply] |
Perhaps you should have included the code in question.
There really isn't a good way to remove newlines and tabs and then later put them back because you'd have to remember exactly where each newline and tab originally was (several ways to do this come to mind but they are all ugly). You can certainly make a copy of the string and remove newlines and tabs from one copy and keep them in the other copy.
So please show us the code in question and be more specific, show sample input and output (both correct and incorrect), etc. We'd be happy to help.
-
tye
(but my friends call me "Tye")
| [reply] |