Skip to content

Commit

Permalink
使用正则匹配代替字符串查找 URL
Browse files Browse the repository at this point in the history
  • Loading branch information
millionart committed May 6, 2018
1 parent 986b139 commit d3b5cad
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions WinPopClip.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,7 @@ GetSelectText()
ClipBoard:=ClipSaved
; 处理协议地址
linkText:=""
findLinkPos:=InStr(selectText, "://")
If (findLinkPos>3)
{
; 把字符串拆分
Loop, Parse, selectText , %A_Tab%%A_Space%`r`n`"
{
findLinkPos:=InStr(A_LoopField, "://")
If (findLinkPos>3)
{
linkText:=A_LoopField
Break
}
}
}
; 从右往左找空格
;ToolTip,%findLinkPos%
; ToolTip,[%selectText%]
RegExMatch(selectText, "(https?|ftp|file|ed2k|thunder)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]", linkText)
}

ShowWinclip()
Expand Down Expand Up @@ -268,6 +252,7 @@ Return

Link:
Gui, Destroy
Try
Run, %linkText%
Return

Expand Down

0 comments on commit d3b5cad

Please sign in to comment.