Jump to content

StringInStr ?


Recommended Posts

Alright... I know how this works...

If StringInStr($messege,"crap") Then
     MsgBox(0,"Warning:","Adult language is being used... lol")
EndIf

But what if I want to search for something like 456... and it occurs like 123456789 StringInStr will not work... So my questions is...

What function would provide me the ability to search a string based on EXACT match?

I'm searching through a website, that website contains this in the HTML, "new_pm.php?uid=XXXXXXX". This dynamic PHP page, adds a little icon inside the members area when you receive new mail. So... All I do is poll the page via InetGet every 30 seconds.... and when that dynamic page changes, to add HTML to supply the icon, it will notify me... Thats easy... Now, what about giving the program to others? I'll need a way to search a line like this

callServer_np('/new_pm.php?uid=XXXXXXX');</script></td></tr></table></td></tr></table></td><td class=header_right><img src=/images/p.gif width=29 height=1>

and retrieve just "/new_pm.php?uid=XXXXXXX" Then I'll be able to implement this program for every user... :)

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

#include <Array.au3>
$String = 'callServer_np("/new_pm.php?uid=XXXXXXX");</script></td></tr></table></td></tr></table></td><td class=header_right><img src=/images/p.gif width=29 height=1>'
$Reg = StringRegExp($String, '(?i)callserver_np.(.*?).;</(?i)script></td>', 3)

_ArrayDisplay($Reg)

Link to comment
Share on other sites

Regular Expressions to the Rescue!!! :)

Const $SourceText = "callServer_np('/new_pm.php?uid=XXXXXXX');</script></td></tr></table></td></tr></table></td><td class=header_right><img src=/images/p.gif width=29 height=1>"
Const $Pattern = "/new_pm\.php\?uid=([^']+)"


Dim $Matches = StringRegExp($SourceText, $Pattern, 1)
Dim $Match = $Matches[0]

ConsoleWrite($Match & @CRLF)

--- TTFN

Link to comment
Share on other sites

Regular Expressions to the Rescue!!! :)

Const $SourceText = "callServer_np('/new_pm.php?uid=XXXXXXX');</script></td></tr></table></td></tr></table></td><td class=header_right><img src=/images/p.gif width=29 height=1>"
Const $Pattern = "/new_pm\.php\?uid=([^']+)"


Dim $Matches = StringRegExp($SourceText, $Pattern, 1)
Dim $Match = $Matches[0]

ConsoleWrite($Match & @CRLF)
You guys are just too awesome! Thanks a lot!!

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

You guys have helped quite a bit, and I hate to revive a thread that's a few weeks old, but... :)

I'm having a few more problems with Strings... I've found StringRegExp() as well as _StringBetween() to be EXCELLENT help, and has improved my scripting quite a bit, but I need to find a specific occurrence of $matched-text... :o

Lets say we have some HTML that looks like...

<something blah=red "#msg2262006">Hey man!</a> <some more HTML>
<something again=red "user/FriendDude101">

<something blah=red "#msg1463406">Yo!</a> <some more HTML>
<something again=red "user/FriendDude101">

<something blah=red "#msg2223336">Windows 7 help!</a> <some more HTML>
<something again=red "user/FriendDude101">

I'm doing a check to see if the Msg-ID has already been caught in the database. So that my program will not notify the same message more than once... But I've had a few users request that the Notification display the User than sent the message... So, seeing that this should be possible with some string functions, how do you search through a file, and pull out a variable such as "/user/FriendDude101" that corresponds to the NEW message ID, which is one line above the username? I'm thinking that _StringBetween() would be the most useful here, but can you split multiple lines of a $Variable into an Array, as a single word?

I'm off to do some testing, I think I may have figured it out... Be back in a bit to let you guys know how it went, if you manage to post something better than _StringBetween() for this operation then...

P.S. I'm currently using StringRegExp() for the UserID and _StringBetween() with UBound for the MSG-ID, because I need a count of the $variables added...

Edit: Again for like the 300th time... lol. I think I may just use FileReadLine() with _StringBetween()... Sound good? I know that's sorta unstable for a Dynamic PHP generated page... but I can't figure anything else out... :D

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...