AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[new problem] RegExMatch
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Mon Dec 15, 2008 8:36 pm    Post subject: [new problem] RegExMatch Reply with quote

trying to get out some information from a html file
cant really get the hang of it...

part of the html
Code:

         <td colspan='3' style="font-size: 10px;">[3541] <a style='text-decoration:none;' href='http://208.100.49.152/mde/gang/272.php' title='Gang Leader'>[<b>SS</b>]</a> <a title='Mobster' style='' href='http://208.100.49.152/mde/profile/3541.php'>Endless</a></td>
      </tr>
      <tr>
         <td style="font-size: 10px;">Level:</td>

         <td colspan='2' style="font-size: 10px;">48</td>
      </tr>
      <tr>
         <td style="font-size: 10px;">Money:</td>
         <td colspan='2' style="font-size: 10px;">$0</td>
      </tr>
      <tr>

         <td style="font-size: 10px;">Points:</td>
         <td style="font-size: 10px;">0</td>
         <td style="font-size: 10px;">[<a href='http://208.100.49.152/mde/elite.php'>buy</a>] [<a href='http://208.100.49.152/mde/point_shop.php'>use</a>]</td>
      </tr>
      </table>


      <tr>
         <td colspan='3' style="font-size: 10px;">[3541] <a style='text-decoration:none;' href='http://208.100.49.152/mde/gang/272.php' title='Gang Leader'>[<b>SS</b>]</a> <a title='Mobster' style='' href='http://208.100.49.152/mde/profile/3541.php'>Endless</a></td>
      </tr>
      <tr>
      
                     <table width="100%" height="10px" style="border: 1px solid #555;"><tr>
                        <td width="100%" style="background-color: #ffcc00;"></td>
                        <td width="0%" style="background-color: #333;"></td>

                     </tr></table>
                  </td>
               

   <div id="right_c"><!-- [ Powered by Mr. Whale's ezRPG ] !--><div class="g_content"><h3>&nbsp;&nbsp;Profile</h3><div class="g_text">   
      <table width='100%'>
      <tr>
         <td colspan='4'>

               

            <table width='100%' height='100%' cellpadding='5' cellspacing='2'>
            <tr>
               <td width='120' align='center'>No avatar!</td>
               <td align='center'><b>Quotes:</b> I am thee Quoteless!
               <br><br>

               <b>Rating:</b> -1<br>
               [<a href='http://208.100.49.152/mde/profile/4922/rate/up.php'>up</a>
                ::
               <a href='http://208.100.49.152/mde/profile/4922/rate/down.php'>down</a>]
               </td>
            </tr>
            </table>

         </td>
      </tr>
      
      <tr>
         <td width='20%'><b>Name</b>:</td>
         <td width='30%'><a style='text-decoration:none;' href='http://208.100.49.152/mde/gang/226.php'>[EMO]</a> <a title='Mobster' style='' href='http://208.100.49.152/mde/profile/4922.php'>Iowa Freak</a></td> ;this name is it that i want
         <td width='20%'><b>HP</b>:</td>

         <td width='30%'>476 / 950 [50%]</td>

      <tr>
         <td><b>Type</b>:</td>
         <td>Mobster</td>
         <td><b>Crimes</b>:</td>

         <td>132</td>
      </tr>
      
      <tr>
         <td><b>Gender</b>:</td>
         <td>Male</td>
         <td><b>Forum Posts</b>:</td>

         <td>1</td>
      </tr>
      
      <tr>
         <td><b>Level</b>:</td>
         <td>20</td>
         <td><b>Money</b>:</td>

         <td>$10,595</td> ; whould also like to find out the money the user has
      </tr>
      
      <tr>
         <td><b>Prison (Caught)</b>:</td>
         <td>2</td>
         <td><b>Prison (Busts)</b>:</td>

         <td>0</td>
      </tr>
      
      <tr>
         <td><b>Age</b>:</td>
         <td>1 days</td>
         <td><b>Last Active</b>:</td>

         <td>4s </td>
      </tr>
      
      <tr>
         <td><b>Online</b>:</td>
         <td><font style='color:green;padding:2px;font-weight:bold;'>[online]</font></td>
         <td><b>Gang</b>:</td>

         <td><a href='http://208.100.49.152/mde/gang/226.php'>Emo Rangers</a></td>
      </tr>



can't find out what i am doing wrong here or whats is missing
trying to find out the Username...
what i also want is to see how much money the user has
my code:
Code:

Url = test.html

Loop, read, %Url%
 {
    IfInString, A_LoopReadLine, profile
       {
         H6=
         Loop, Parse,A_Loopreadline ,><,`
             H%A_Index%  := A_LoopField
      }   
    IfInString, A_LoopReadLine, money
       {
         m6=
         Loop, Parse,A_Loopreadline ,><,`
             m%A_Index%  := A_LoopField
      }
 }
msgbox, (
username = %h6% ;its gona say "Iowa Freak"
%h6% has this much money: %m2%
)

_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...


Last edited by lilljimpa on Wed Dec 17, 2008 7:32 pm; edited 3 times in total
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Mon Dec 15, 2008 8:54 pm    Post subject: Reply with quote

This seems to do it
Code:
FileRead, Data, test.html
RegExMatch(Data,"\<b>Name.*?\<a title='Mobster'[^\>]+\>([^\<]+?)\</a>.*?Money\</b>:.*?\$([\d\,]+)",UName)
MsgBox %UName1% has $%UName2%
Note that the variable containing the username is UName1, and the variable containing the amount of money is UName2

EDIT: Oops, forgot the money part. Fixed now Smile
_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.


Last edited by Slanter on Mon Dec 15, 2008 9:33 pm; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 2214
Location: switzerland

PostPosted: Mon Dec 15, 2008 8:59 pm    Post subject: Reply with quote

must search for something unique in searched line , here EMO ?
Code:
Url = test.html
Loop, read, %Url%
 {
    IfInString, A_LoopReadLine, EMO
         {
         user=
         H9=
         Loop, Parse,A_Loopreadline ,><,`
             H%A_Index%  := A_LoopField
         user=%H9%
         }
 }
msgbox, %user%
Back to top
View user's profile Send private message
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Mon Dec 15, 2008 9:15 pm    Post subject: Reply with quote

thats not a good search for, because thats there gang short name
so thats is individual for each user
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Mon Dec 15, 2008 9:29 pm    Post subject: Reply with quote

Slanter wrote:
This seems to do it
Code:
FileRead, Data, titan_burn.htm
RegExMatch(Data,"\<b>Name.*?\<a title='Mobster'[^\>]+\>([^\<]+?)\</a>.*?Money\</b>:.*?\$([\d\,]+)",UName)
MsgBox %UName1% has $%UName2%
Note that the variable containing the username is UName1, and the variable containing the amount of money is UName2

EDIT: Oops, forgot the money part. Fixed now Smile


hmm, thats dont works so good for me.. only got msg "has $"
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Mon Dec 15, 2008 9:32 pm    Post subject: Reply with quote

hmm... it worked on the example html you gave me.
_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Mon Dec 15, 2008 9:52 pm    Post subject: Reply with quote

Slanter wrote:
hmm... it worked on the example html you gave me.


i even tried out my own example and your code
can it be any system requirement?
got winXP sp3 and latest AHK
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Mon Dec 15, 2008 9:59 pm    Post subject: Reply with quote

System shouldn't have anything to do with it... did you change the file name to your test file?
_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Mon Dec 15, 2008 10:04 pm    Post subject: Reply with quote

yea, i eaven added a small check

Code:
FileRead, Data, test.html
 if not ErrorLevel  ; Successfully loaded.
  msgbox, test.html exist
RegExMatch(Data,"\<b>Name.*?\<a title='Mobster'[^\>]+\>([^\<]+?)\</a>.*?Money\</b>:.*?\$([\d\,]+)",UName)
MsgBox %UName1% has $%UName2%


and the first msg was displayed
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Mon Dec 15, 2008 10:09 pm    Post subject: Reply with quote

Try this
Code:
FileRead, Data, test.html
 if not ErrorLevel  ; Successfully loaded.
  msgbox, test.html exist
RegExMatch(Data,"\<b>Name(?:.|`r)*?\<a title='Mobster'[^\>]+\>([^\<]+?)\</a>(?:.|`r)*?Money\</b>:(?:.|`r)*?\$([\d\,]+)",UName)
MsgBox %UName1% has $%UName2%

_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Mon Dec 15, 2008 10:25 pm    Post subject: Reply with quote

yupp that mad it work Very Happy
but why not the previus Shocked Question
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Mon Dec 15, 2008 10:28 pm    Post subject: Reply with quote

I had accidentally saved mine using an editor that only seperated lines with a line feed (0x0A, `n), while it should have been carriage return (0x0D, `r) line feed. RegEx doesn't seem to like that combo with wild cards, so I had to change all the ".*" to "(?:.|`r)*".
_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
lilljimpa



Joined: 18 Apr 2007
Posts: 127

PostPosted: Mon Dec 15, 2008 10:37 pm    Post subject: Reply with quote

what editor did u use? maybe could get in handy for me
_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 739
Location: Minnesota, USA

PostPosted: Mon Dec 15, 2008 10:39 pm    Post subject: Reply with quote

Notepad++
_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
Frankie



Joined: 02 Nov 2008
Posts: 2850

PostPosted: Mon Dec 15, 2008 10:41 pm    Post subject: Reply with quote

Is there any way to change this in notepad++? Just wondering
_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group