Kyan

Stringregexp get recurrent match between html tags

6 posts in this topic

#1 ·  Posted (edited)

Hi, I'm trying to get the language tags (pt_pt, en_gb,...) and their data "ALLWORK" in this case, why isn't it working?

$aPreDATA = '<div data-type="inputText" name="title" data-multilang data-legend="Título"  data-force><pt_pt>ALLWORK</pt_pt><en_gb>ALLWORK</en_gb><fr_fr>ALLWORK</fr_fr><de_de>ALLWORK</de_de></div>'
$atitle = StringRegExp($aPreDATA,'(?i)<div data-type="inputText" name="title".*?>(?:<(\w{2}_\w{2})>(.+?)</\g-1>)+?</div>',3)
_ArrayDisplay($atitle)

Also tried this and no luck

$aPreDATA = '<div data-type="inputText" name="title" data-multilang data-legend="Título"  data-force><pt_pt>ALLWORK</pt_pt><en_gb>ALLWORK</en_gb><fr_fr>ALLWORK</fr_fr><de_de>ALLWORK</de_de></div>'
$atitle0 = StringRegExp($aPreDATA,'(?i)<div data-type="inputText" name="title".*?>(.+?)</div>',3)
$atitle = StringRegExp($atitle0,'(?i)<(\w{2}_\w{2})>(.*?)</',3)

Thanks in advance

Edited by Kyan

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi,

#include<array.au3>
$aPreDATA = '<div data-type="inputText" name="title" data-multilang data-legend="Título"  data-force><pt_pt>ALLWORK</pt_pt><en_gb>ALLWORK</en_gb><fr_fr>ALLWORK</fr_fr><de_de>ALLWORK</de_de></div>'
$atitle = StringRegExp($aPreDATA,'(?i)(\w{2}_\w{2})>(.+?)<\/\g1>',3)
_ArrayDisplay($atitle)

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

Or this..

$atitle = StringRegExp($aPreDATA, '<\w{2}_\w{2}>([^<]+)', 3)

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

regexp is lazy :)

#include<array.au3>
$sPreDATA = '<div data-type="inputText" name="title" data-multilang data-legend="Título"  data-force><pt_pt>ALLWORK</pt_pt><en_gb>ALLWORK</en_gb><fr_fr>ALLWORK</fr_fr><de_de>ALLWORK</de_de></div>'
$aSplit = stringsplit(stringtrimleft(stringtrimright($sPreData , 6) , stringinstr($sPreDATA , "data-force>") + stringlen("data-force>") - 1) , "><" , 2)
_ArrayDisplay($aSplit)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#5 ·  Posted

Lazy ? noooo. Just a little misunderstanding - maybe  :)

$atitle = StringRegExp($aPreDATA, '(<\w{2}_\w{2}>)([^<]+)', 3)

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

that one is even lazier+

:)


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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