Jump to content

Search text file and then find value


Romm
 Share

Recommended Posts

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=??

Link to comment
Share on other sites

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!

Link to comment
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?

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...