AutoHotkey Community

It is currently May 27th, 2012, 1:23 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: August 31st, 2008, 9:26 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Thanks Krogdor! I had tried using \ to escape them thinking it was just a regex thing, I didn't know this double quotes is for all expressions.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 1:49 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
IMHO the 1st valid v2 attempt, since it generates the requested Target from one RegEx :P

Code:
If !(Fileexist( A_Temp "\g_index.htm"))
   URLDownloadToFile, http://www.google.com/ncr, %A_Temp%\g_index.htm
FileRead, Haystack, %A_Temp%\g_index.htm

Needle=((h.{6}w[^/]+)/).*(0.{5}"([^"]+)")

If (RegExMatch(HayStack,Needle,m))
   Result := m2 m4
else
   Result := "Not found"

MsgBox % Result  "`n`nRegExNeedleLength: " StrLen(Needle) "`n" Needle

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 2:22 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
DerRaphael wrote:
IMHO the 1st valid v2 attempt, since it generates the requested Target from one RegEx :P


What about mine?
Code:
URLDownloadToFile, http://www.google.com/ncr, %A_Temp%\g_index.htm
FileRead, Haystack, %A_Temp%\g_index.htm
RegExMatch(Haystack,"ue=(.+?)/"".+110 src=""(.+?)""",Output)
MsgBox % Output1 Output2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 2:25 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
Code:
HayStack Code moved to http://itholic.org/ahk/demo/heresy.regExTraining.v2.google_index_html.txt


using this as my google sourcepage generates a blank output

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Last edited by derRaphael on September 8th, 2008, 3:00 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 2:51 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Huh. Your source is a bit different than mine. Anyway, this will accommodate your source as well:

Code:
RegExMatch(Haystack,"ue=(.+?)/[^/]*?"".+110 src=""(.+?)""",Output)
MsgBox % Output1 Output2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 2:54 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
Code:
Needle=ue=(.{21}).*0.{5}"([^"]+)"
If (RegExMatch(HayStack,Needle,m))
   Result := m1 m2
else
   Result := "Not found"

MsgBox % Result  "`n`nRegExNeedleLength: " StrLen(Needle) "`n" Needle


this should work aswell

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 3:07 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
Krogdor wrote:
Huh. Your source is a bit different than mine. Anyway, this will accommodate your source as well:

Code:
RegExMatch(Haystack,"ue=(.+?)/[^/]*?"".+110 src=""(.+?)""",Output)
MsgBox % Output1 Output2


works, too :) (RegExLength 33 Chars)

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 3:31 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
Maybe this helps in streamlining the training and giving proper results :)
Code:
If !(Fileexist( A_Temp "\g_index.htm"))
   URLDownloadToFile
      , http://itholic.org/ahk/demo/heresy.regExTraining.v2.google_index_html.txt
      , %A_Temp%\g_index.htm
FileRead, Haystack, %A_Temp%\g_index.htm

VersionInfo_1 := "DerRaphael Attempt1"
Needle_1      := "((h.{6}w[^/]+)/).*(0.{5}""([^""]+)"")"
OutVars_1     := "%m2%%m4%"

VersionInfo_2 := "Krogdor Attempt2"
Needle_2      := "ue=(.+?)/[^/]*?"".+110 src=""(.+?)"""
OutVars_2     := "%m1%%m2%"

VersionInfo_3 := "DerRaphael Attempt2"
Needle_3      := "ue=(.{21}).*0.{5}""([^""]+)"""
OutVars_3     := "%m1%%m2%"

Result        := ""
ul            := "================================"
Loop,3
{
   Result .= VersionInfo_%A_Index% "`n" ul "`n`n"
   RegExMatch(HayStack,Needle_%A_Index%,m)
   Transform, out, Deref, % OutVars_%A_Index%
   If (out=="http://www.google.com/intl/en_ALL/images/logo.gif") {
      Result .= "Match found"
              . "`nRegExNeedleLength: " StrLen(Needle_%A_Index%) "`n"
              . Needle_%A_Index% "`n`n" ul "`n"
   } else
      Result .= "Match not found"
}
MsgBox % Result


greets
dR

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 8th, 2008, 3:46 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Code:
Needle = ue=(.{21}).+c="(.+?)"
RegExMatch(Haystack,Needle,Output)
MsgBox % Output1 Output2


This will work as well.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group