how to replace a word or , or bracket

Discussion, questions and support.
Post Reply
mragtronx8
Posts: 42
Joined: Feb 2nd, ’20, 08:36

Post by mragtronx8 » Oct 17th, ’21, 06:53

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
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » 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
mragtronx8
Posts: 42
Joined: Feb 2nd, ’20, 08:36

Post by mragtronx8 » Oct 17th, ’21, 10:31

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
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » 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
mragtronx8
Posts: 42
Joined: Feb 2nd, ’20, 08:36

Post by mragtronx8 » Oct 17th, ’21, 13:22

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 :)
mragtronx8
Posts: 42
Joined: Feb 2nd, ’20, 08:36

Post by mragtronx8 » Oct 17th, ’21, 16:21

can the result be saved in the clipboard
instead of opening notepad and pasting the result there

thx again
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Oct 18th, ’21, 10:47

Replace the last line with
Clipboard:=String
Post Reply