Jump to content

Recommended Posts

Posted

Hello, so im trying to put together a regular expression to grab some variables from input fields on a website. Here is what the code on the website looks like:

<form id="activation" method="post" action="" >
<h1 class="title">Information</h1>
<div class="input2">
<h2>code:</h2>
<input type="text" name="" value="rtx3g3" class="textfield" readonly />
</div>
<div class="input2">
<h2>Password:</h2>
<input type="text" name="" value="q4KDL" class="textfield" readonly />
</div>
</form>

Ive tried using the following to get the value field from the code

$result = StringRegExp($HTML, 'value="([a-zA-Z0-9]+)"', 1)

I'm pretty new to regular expressions so if there is a better way to do it let me know. I don't know if there will always only be 6 characters, so this was just a guess, but since it isnt giving me anything, i figure i did something wrong. Since there is more than one instance of the value on the page, it will put both instances of the value into an array correct?

Posted (edited)

Try this:

$aResult = StringRegExp($HTML, '(?i)value="(.*)" class.*', 3)
_ArrayDisplay($aResult)

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Thanks, tried what you posted, but it doesn't quite work. I threw out a message box at the end and $aResult equals 1 if i try to put in $aResult[0] it tells me that $aResult isnt an array.

Posted

I put the html code from your 1st post to test.html

#include <Array.au3>
$html = FileRead(@ScriptDir & "\test.html")
$aResult = StringRegExp($HTML, '(?i)value="(.*)" class.*', 3)
If Not @error Then _ArrayDisplay($aResult)

The result are 2 values.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

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