Script error search google
Posted: Dec 10th, ’21, 02:25
I wrote this script and when selecting the urls to search for a page it works correctly, but if I select a word it shows an error in regEx and then it searches for it. This is the code:
Code: Select all
Clipboard =
Send ^c
ClipWait, 0
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Else Run, % Clipboard ~= "\b(?:https?://)?(?:(?i:[a-z]+\.)+)[^\s,]+\b"
? Clipboard : fix("https://www.google.com/search?q=" Clipboard)
Return
fix(url) {
RegExMatch(url, "^(https?://)?(.+?)(/)?$", part)
Loop, Parse, part2
text .= A_LoopField ~= "[$&+,:;@""<>`%{}|\\^~[\] `]" ? Format("%{:X}", Asc(A_LoopField)) : A_LoopField
Return part1 text part3
}