Page 1 of 1

how to replace a word or , or bracket

Posted: Oct 17th, ’21, 06:53
by mragtronx8
could u please advise.
I sometimes copy text from the web, and want to paste it in a folder; but i want to have an option to remove certain words like "Default or Beta or Multi or etc" and also remove " .,[]{}()-_ "
And want to replace these with " SPACE "

eg:- John.2021_Multi-Smith => John 2021 Smith

thx in advance

Re: how to replace a word or , or bracket

Posted: Oct 17th, ’21, 10:16
by Tom
Something like this?

Code: Select all

string:=Clipboard
replacements:=".;,;[;];{;};(;);-;_;Default;Beta;Multi;etc" 
loop, parse, replacements, `;
	StringReplace, string, string, %A_LoopField%, %A_Space%, all
loop
	StringReplace, string, string, %A_Space%%A_Space%,%A_Space%, UseErrorLevel
until !ErrorLevel

sendinput, % string

Re: how to replace a word or , or bracket

Posted: Oct 17th, ’21, 10:31
by mragtronx8
Tom wrote: Oct 17th, ’21, 10:16 Something like this?

Code: Select all

string:=Clipboard
replacements:=".;,;[;];{;};(;);-;_;Default;Beta;Multi;etc" 
loop, parse, replacements, `;
	StringReplace, string, string, %A_LoopField%, %A_Space%, all
loop
	StringReplace, string, string, %A_Space%%A_Space%,%A_Space%, UseErrorLevel
until !ErrorLevel

sendinput, % string
thx Tom,
can u please adjust it also to remove " ; " & "the space at the end"
a space is being added to the end

Re: how to replace a word or , or bracket

Posted: Oct 17th, ’21, 12:31
by Tom

Code: Select all

string:=Clipboard
replacements:=",|.|,|[|]|{|}|(|)|-|_|Default|Beta|Multi|etc" 
loop, parse, replacements, |
	StringReplace, string, string, %A_LoopField%, %A_Space%, all
loop
	StringReplace, string, string, %A_Space%%A_Space%,%A_Space%, UseErrorLevel
until !ErrorLevel
string=%string%
sendinput, % string

Re: how to replace a word or , or bracket

Posted: Oct 17th, ’21, 13:22
by mragtronx8
Tom wrote: Oct 17th, ’21, 12:31

Code: Select all

string:=Clipboard
replacements:=",|.|,|[|]|{|}|(|)|-|_|Default|Beta|Multi|etc" 
loop, parse, replacements, |
	StringReplace, string, string, %A_LoopField%, %A_Space%, all
loop
	StringReplace, string, string, %A_Space%%A_Space%,%A_Space%, UseErrorLevel
until !ErrorLevel
string=%string%
sendinput, % string
PERFECT
THX :)

Re: how to replace a word or , or bracket

Posted: Oct 17th, ’21, 16:21
by mragtronx8
can the result be saved in the clipboard
instead of opening notepad and pasting the result there

thx again

Re: how to replace a word or , or bracket

Posted: Oct 18th, ’21, 10:47
by Tom
Replace the last line with
Clipboard:=String