Jump to content
Sign in to follow this  
tom13

get Z between X and Y from a string

Recommended Posts

tom13

Sigh... I wrote tons of text in this thread and it somehow all got deleted after I pressed submit.. probably some forum bug when there is too much text?

Okay.. I'll make it short this time.

I want to get a string from a string with _StringBetween

The string looks like this: "<divclass="health-stat"><h4>Health:</h4><p><span>12065</span></p></div>"

So I coded this:

#include <INet.au3>
#include <String.au3>

$url = "http://eu.wowarmory.com/character-sheet.xml?r=Stormscale&n=Sodar"
$rawsource = _INetGetSource ($url)
$source = StringStripWS($rawsource, 8)

$health_start = "<h4>Health:</h4><p><span>"
$health_end = "</span></p>"
$health = _StringBetween ( $source, $health_start, $health_end)

MsgBox(4096, "Test", $health, 10)

But when I execute it it gives me an empty string as return.. anyone knows why or what I do wrong?

It should, in the example above, return "12065"

Edited by tom13

Share this post


Link to post
Share on other sites
tom13

erm for some reason there is no text? I wrote so much and now there is nothing..

edit: remade it in a short version

Edited by tom13

Share this post


Link to post
Share on other sites
SmOke_N

1. You need to look up "escape characters" if you are going to use the RegExp part of _StringBetween.

2. The return value is not a regular variable, it's an Array.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
tom13

1. You need to look up "escape characters" if you are going to use the RegExp part of _StringBetween.

2. The return value is not a regular variable, it's an Array.

thanks! didn't know I had to use an array because its only found 1 time

Share this post


Link to post
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
Sign in to follow this  

×