Jump to content

StringRegExp of url


Tormiasz
 Share

Recommended Posts

Hello.

I am getting the whole site by InetRead and BinaryToString functions and I want to get the array of ALL the words that are maching this url

<a href="http://www.asd.com/abc/?new=yaya&xyz=Name>Name</a>

I want to get the "Name"'s into array.

Can anyone help me?

Edited by Tormiasz
Link to comment
Share on other sites

Hi,

#include <Array.au3>
 
$s = 'href="http://www.asd.com/abc/?new=yaya&xyz=Name">Name</a>'
 
$a = StringRegExp($s, '(?m)href="http://www.asd.com/abc/\?new=yaya&xyz=Name">(.*?)</a>', 3)
 
_ArrayDisplay($a)
Edit: If "Name" is always a word then replace (.*?) by (w+), if it can have spaces then ([ws]+)

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Someting is wrong

for example

There will be Two lines (names are generated randomly)

<a href="http://www.asd.com/abc/?new=yaya&xyz=First Name>First Name</a>
<a href="http://www.asd.com/abc/?new=yaya&xyz=Second Name>Second Name</a>

Your method is not working properly for me. IDK why.

Link to comment
Share on other sites

If the word to search is the same in the end of the url as in the a value then:

#include <Array.au3>

$sWord = "toto"

$s = 'href="http://www.asd.com/abc/?new=yaya&xyz=' & $sWord & '">' & $sWord & '</a>'

$a = StringRegExp($s, '(?m)href="http://www.asd.com/abc/\?new=yaya&xyz=(.*?)">', 3)

_ArrayDisplay($a)
Br, FireFox.
Link to comment
Share on other sites

Im not great with regexp but the below works for me.

#include <Array.au3>

$vSource = 'href="http://www.asd.com/abc/?new=yaya&xyz=Name">Name</a>href="http://www.asd.com/abc/?new=yaya&xyz=First Name">First Name</a>href="http://www.asd.com/abc/?new=yaya&xyz=Second Name">Second Name</a>'

$vRegExp = StringRegExp($vSource, 'href="http://www.asd.com/abc/\?new=yaya&xyz=.*?">(.*?)</a>', 3)

_ArrayDisplay($vRegExp)

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

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