Jump to content
Sign in to follow this  
Tormiasz

StringRegExp of url

Recommended Posts

Tormiasz

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

Share this post


Link to post
Share on other sites
FireFox

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Tormiasz

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.

Share this post


Link to post
Share on other sites
FireFox

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.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
mrflibblehat

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]

Share this post


Link to post
Share on other sites
Tormiasz

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

This one works well.

Thank you for the help.

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  

×