How to replace text with regular expression? #2530
Replies: 2 comments 1 reply
-
Try this: copyq:
var raw = str(clipboard())
var processed = raw.replace(new RegExp("matched text", "g"), "replaced text")
copy(processed)
paste() |
Beta Was this translation helpful? Give feedback.
1 reply
-
I found a piece of code that wasn't intended for this, but modified it and it works.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The text I'm going to copy
magnet:?xt=urn:btih:fc0a90cb47251361d696fd2057e82d3f3ee2b108&dn=zh-cn_windows_10_business_editions_version_22h2_updated_oct_2023_x64_dvd_eb713365.iso&xl=6467465216
I want it to show up inside CopyQ as
magnet:?xt=urn:btih:fc0a90cb47251361d696fd2057e82d3f3ee2b108
I can use regular matching, but I don't know how to replace it. Please help.😵
^(magnet:\?xt=urn:btih:\w{40}).+
Beta Was this translation helpful? Give feedback.
All reactions