Jump to content

regrexp help


Recommended Posts

hi guy i try to learn  regrexp 

i use  regexbuddy 

i want  take  a part of  this code 

<div class="contList" abp="100">
<ul class="unstyled" id="categoryList" abp="101">
  <li class="btn btn-small gradient eleCat" abp="102"><a
 href="/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&amp;codFamiglia=HE0"
 abp="103">CD PLAYERS</a></li>
  <li class="btn btn-small gradient eleCat" abp="104"><a
 href="/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&amp;codFamiglia=HE6"
 abp="105">CD RECORDERS</a></li>
  <li class="btn btn-small gradient eleCat" abp="106"><a
 href="/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&amp;codFamiglia=HE4"
 abp="107">CD/CASSETTE PLAYERS</a></li>

i try to use  this  expression for  take 

'(?i)abp=".+?"><a\n href="(*.?)"'

but  tell me  RegexBuddy does not yet support backtracking control verbs

and in autoit  not  run 

some on can help me ??  thankz  at  all  for patient 

Link to comment
Share on other sites

I don't really understand what is the expected result...

Try this :

$aResult1 = StringRegExp($sHTML, '(?is)abp="(\d+)"><a\s+href="([^"]+)"', 3)
_ArrayDisplay($aResult1)

$aResult1 = StringRegExp($sHTML, '(?is)<a\s+href="([^"]+).+?abp="(\d+)"', 3)
_ArrayDisplay($aResult1)
Edited by jguinch
Link to comment
Share on other sites

i trye d to take  cd-palyers   cd recorders ....

i try to use  this  

in regexbuddy  is ok  but in autoit  not  go  why §??? 

where is  the problem?? 

(?i)FAmiglia=.+?"\n abp=".+?">(.*?)</a></li>
Link to comment
Share on other sites

is this close, i still dont really understand the goal.  But i am guessing its one of these two things.

#include<array.au3>
$sFile = fileread("file.txt")

$sFile = stringstripws($sFile, 8)

$aMatches = stringregexp( $sFile , 'href=(.*?)abp="\d+">(.*?)</a></li>' , 3)

_ArrayDisplay($aMatches)

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

Link to comment
Share on other sites

Please, next time post your AutoIt code, even if it doesn't work :rolleyes: 

Your expression could be :

StringRegExp($sHtml, '(?i)FAmiglia=.+?"\s+abp=".+?">(.*?)<\/a><\/li>', 3)

Or

StringRegExp($sHtml, "(?s)<a\s.*?>([^<]+)", 3)
Link to comment
Share on other sites

A non-regexp route:

$sXML = '<div class="contList" abp="100"><ul class="unstyled" id="categoryList" abp="101"><li class="btn btn-small gradient eleCat" abp="102"><a href="/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&amp;codFamiglia=HE0" abp="103">CD PLAYERS</a></li>  <li class="btn btn-small gradient eleCat" abp="104"><a href="/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&amp;codFamiglia=HE6" abp="105">CD RECORDERS</a></li>  <li class="btn btn-small gradient eleCat" abp="106"><a href="/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&amp;codFamiglia=HE4" abp="107">CD/CASSETTE PLAYERS</a></li></ul></div>'

$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.loadxml($sXML)
$oLinks = $oXML.selectNodes("//ul/li/a")
For $oLink in $oLinks
    $sHref = $oLink.getattribute("href")
    $sAbp = $oLink.getattribute("abp")
    ConsoleWrite("$sHref=[" & $sHref & "]; $sAbp=[" & $sAbp & "]" & @CRLF)
Next

output:

$sHref=[/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&codFamiglia=HE0]; $sAbp=[103]
$sHref=[/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&codFamiglia=HE6]; $sAbp=[105]
$sHref=[/b2b/Ricerche/FantaRicerca/MostraFiltri?catMerc=HE&codFamiglia=HE4]; $sAbp=[107]

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

It works on xml, but not generally on full html source.  Html is similar, but not an exact match.

For snippets like this, it's good to go.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...