Good day all,
I am writing a little macro in which I want to
- show a prompt() to the user, in which the *default text* is taken from what is
currently selected in the window by the user.
But the string that is currently selected might be "dirty" - include
newlines and other trash characters..
[Here's the prob:]
I would like to "clean" this string - only keep alphanumerics and spaces (and hyphens perhaps) but no trash. Any ideas?
It's probably not possible, right? Requires some simple RegExp support, I would think..
code so far:
$old_clip = getclipboard();
# Get currently selected:
$q = getclipboard();
#Here, I do a little cleaning:
$q = gsub( "\n", " ", $q );
$q = gsub( " ", " ", $q );
# But it's not really enough.. Have only removed the \n
# The same for \r won't work :-(
# The default stríng in the following prompt still gets ugly..
$strings = prompt('A prompt..', ' ..with an ugly default string: ', $q);
Any ideas appreciated!