Jump to content

Recommended Posts

Posted

I made a few attempts, but it fails when there are too many lines

href = "and url between #

My regular expression test

<a\shref=[\"](.*?)#post

or

(?i)<a\s*href=[\"].*?([^\#]+)#

 

Html code sample

</a>  <a href="https://example.com/asdf#post70403235"><img class="

 

Posted (edited)

If Mikel is like that

<a href="https://example.com/abcde" >abcde</a>  <a href="https://example.com/asdf#post70403235"><img class="

 

And this is what I need

https://example.com/asdf

'href="[^#](.*)#'

Edited by youtuber
Posted
$s = '<a href="https://example.com/abcde" >abcde</a>  <a href="https://example.com/asdf#post70403235"><img class=" '

msgbox(0, '' , stringreverse(stringsplit(stringreverse(stringsplit($s , "#" , 2)[0]) , '"' , 2)[0]))

as expected from me :)

  Reveal hidden contents

Posted

@iamtheky This is the first time I see this method :o

How do I get the return data with this method?
How it is used?

Sample

$aGetConnect = stringreverse(stringsplit(stringreverse(stringsplit(WebConnect("https://www.autoitscript.com/forum/"), "#" , 2)[0]) , '"' , 2)[0])
ConsoleWrite("Receive data: " & $aGetConnect & @CRLF)

Func WebConnect($address)
    Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    $oHTTP.Open("GET", $address, False)
    $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0")
    $oHTTP.SetRequestHeader("Accept", "*/*")
    $oHTTP.SetRequestHeader("Accept-Language", "tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3")
    $oHTTP.Send()
    If @error Then
        ConsoleWrite("Error connection")
        $oHTTP = 0
        Return SetError(1)
    EndIf

    If $oHTTP.Status = 200 Then
        Local $sReceived = $oHTTP.ResponseText
        $oHTTP = Null
        Return $sReceived
    EndIf

    $oHTTP = Null
    Return -1
EndFunc

 

Posted

I just like manipulating strings without regexp for sport. I have no idea what nesting your function into that rats nest of string ops will yield.

Regex is most certainly the solution you want to use, especially for maintenance purposes.

  Reveal hidden contents

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