Sign in to follow this  
Followers 0
Romm

Search text file and then find value

6 posts in this topic

2F&gender=1&lvl=2&const=501&sk=6&mount=0&hp=53&hpMax=53&hpT=0&mp=67&mpMax=67&mpT=0&parts=

This is part of HTML code. I need to find "hp=" and then "cut" numbers to the right (here - 53).

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use StringInStr to get position, then various other String funcs to manipulate

Edited by whim

Share this post


Link to post
Share on other sites

Returns the new string, the number of replacements performed is stored in @extended.

This is not what i need.

2F&gender=1&lvl=2&const=501&sk=6&mount=0&hp=53&hpMax=53&hpT=0&mp=67&mpMax=67&mpT=0&parts=

This code shows how many health and mana your character has.

"hp=" and "mp=" are current health and mana. For example hp=53&hpMax=53&mp=67&mpMax=67. How to get value of hp=??

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

2F&gender=1&lvl=2&const=501&sk=6&mount=0&hp=53&hpMax=53&hpT=0&mp=67&mpMax=67&mpT=0&parts=

This is part of HTML code. I need to find "hp=" and then "cut" numbers to the right (here - 53).

Use FileReadToArray($MyHtmlFile,$MyArray) to get your file's content to an array.

Then search all array values ($i = 1 to $MyArray[0]) for your "hp=n[n....]"

StringRegExp($MyArray[$i],"hp=\d+",1)

"hp=" will give you the part in the line starting with "hp="

"\d" is any directly following numeric char. (0-9)

"+" tells regex to find the previous specified char at least one time.

Have a look to the help for RegEx and other string operators.

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

This is not what i need.

2F&gender=1&lvl=2&const=501&sk=6&mount=0&hp=53&hpMax=53&hpT=0&mp=67&mpMax=67&mpT=0&parts=

This code shows how many health and mana your character has.

"hp=" and "mp=" are current health and mana. For example hp=53&hpMax=53&mp=67&mpMax=67. How to get value of hp=??

first he is right use StringinStr:

#include <String.au3>

$m="hp=53&hpMax=53&mp=67&mpMax=67"
$p=stringinstr ($m,"hp=",1)
$n=$p+4
$n1=stringmid ($m,$p,$n)
$n2=stringsplit ($n1,"=")
$n3=$n2[2]
MsgBox (0,"",$n3)

by the way did you use the network sniffer?

Share this post


Link to post
Share on other sites

by the way did you use the network sniffer?

no but im thinking about this now...

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  
Followers 0