Sure! You can "name that tune" in just one line... but is it worth the effort? I mean, "one line vs. two?"
(He continued, quietly putting on his Perl hat... neatly embroidered "TMTOWTDI")
If you do want to do it, even as just an exercise in frustration , then regular-expressions are the right tool to use. REReplaceNoCase() is, indeed, the function you want. A regular-expression can be written which matches, as you say, "blank spaces, slashes ("/" and "\"), etc." Then you use the function to replace "all" occurrences with an underscore.
Now, having said that ... "never mind what is 'efficient.' What is abundantly clear?" The regular expression would indeed be "clear enough," but the difference between "one" and "a few" lines-of-code might be, literally, not worth the time. Your call.
I agree with TLC-IT that in many cases regular expressions can be more trouble than they're worth, but in this particular instance the expression needed is simple enough that it would simplify the code a bit - especially down the road if you run across other characters that need to be replaced. The code would look something like this: <cfset string = reReplaceNoCase(trim(arguments.queryObject[item][i]),"[\s\\/]","_","all") />
Oh yes, I agree entirely. If uttering the word, "regular expression" does not produce and reactions in your "shop," they are positively the cat's meow for string-munching tasks exactly like this one. If your co-workers can instantly understand and grok what you have written, then this is an incredibly powerful feature of the language, and ideal for this very application. I'm just cautioning that "regular-expressions can become 'write-only.' If they produce blank looks, stick to whatever is abundantly clear." Or, leave a good book on Regular Expression Syntax sitting strategically close to the vending-machine.
<cfset resourcename="tets\sdgg fjsjd/">