 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
DevX
Joined: 07 Jan 2009 Posts: 43
|
Posted: Tue Jul 07, 2009 3:37 pm Post subject: RegExMatch - Between http and ' or " |
|
|
Hey guys,
Can't seem to get this right, I have this "Needle" for regex
| Code: |
Needle := "http.*?aspx.*?(?=.*""?'?)"
Needle2 := "http.*?aspx""?'?"
|
But not working as intended (neither of the two). I basically want to match everything between an http and either a ' or a " (quote or double quote)
so like in this
javascript:cmCreateManualLinkClickTagURL('http://www.test.com/todays-special.aspx?ocm=todspc&cm_re=billboard1*ts*~!@#$PositionToken~!@#$','', cG7.cM0[cm_ClientID]);"
it should only get
http://www.hsn.com/todays-special_xh.aspx?ocm=todspc&cm_re=billboard1*ts*~!@#$PositionToken~!@#$' |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Tue Jul 07, 2009 3:47 pm Post subject: |
|
|
Like this?
| Code: | var = javascript:cmCreateManualLinkClickTagURL('http://www.test.com/todays-special.aspx?ocm=todspc&cm_re=billboard1*ts*~!@#$PositionToken~!@#$','', cG7.cM0[cm_ClientID]);"
MsgBox % RegExReplace(var, ".*?(http[^']+).*","$1") |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
DevX
Joined: 07 Jan 2009 Posts: 43
|
Posted: Tue Jul 07, 2009 3:57 pm Post subject: |
|
|
I dont even know how thats working... lol
It works in your example, but blows up in mine...
| Code: | ;Test := "<a href=""http://www.hsn.com/moonlight-festival-blogs_g-125_xg.aspx?reset=1&word=mist"">apples</a><a href=""http://www.hsn.com/moonlight-festival-blogs _g-125_xg.aspx"">oranges</a>"
;Test := "<a href=""http://www.hsn.com/moonlight-festival-blogs_g-125_xg.aspx?reset=1&word=mist"">apples</a><a href=""http://www.hsn.com/moonlight-festival-blogs_g-125_xg.aspx"">oranges</a>"
Test := Clipboard
;Needle := "http.*?aspx.*?(?=.*""?'?)"
Needle := ".*?(http[^']+).*"
Needle2 := "http.*?aspx""?'?"
Start := 1
mCount := 0
Errors := "Please fix these and rerun script`n"
Errors_Default := StrLen(Errors)
loop
{
FoundPos := RegExMatch(Test, Needle, Output, Start)
if FoundPos = 0
{
FoundPos := RegExMatch(Test, Needle2, Output, Start)
if FoundPos = 0
break
}
Start := FoundPos + StrLen(Output)
StringReplace, Output, Output, ",,All
Test_Space := InStr(Output, A_Space)
if Test_Space
Errors := Errors . "Space at #" . Test_Space . " -- " . Output . "`n"
TmpText%A_Index% := Output
mCount += 1
}
if (StrLen(Errors) > Errors_Default)
{
; Error out
MsgBox % Errors
}
else
{
; Execute
loop %mCount%
{
MsgBox % TmpText%A_Index%
}
}
|
|
|
| Back to top |
|
 |
DevX
Joined: 07 Jan 2009 Posts: 43
|
Posted: Tue Jul 07, 2009 4:56 pm Post subject: |
|
|
Got it =D
Thx for the help |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|