Sign in to follow this  
Followers 0
horne

Problem with string

30 posts in this topic

How i can clean that one

&flv_addr=media08.website.com/s/b9/b9cf1f95fd.flv&jpg_addr=i48.website.com/p/b9cf1f95fd4.jpg&subsEnabled=false&related=1

to become

media08.website.com/s/b9/b9cf1f95fd.flv

Thanks in advance

Share this post


Link to post
Share on other sites



horne,

This works for me: :)

$sText = "&flv_addr=media08.website.com/s/b9/b9cf1f95fd.flv&jpg_addr=i48.website.com/p/b9cf1f95fd4.jpg&subsEnabled=false&related=1"

$sExtract = StringRegExpReplace($sText, ".*addr=(.*)&jpg_addr=.*", "$1")

MsgBox(0, "Extract", $sExtract)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Try this:

#include <String.au3>
$sIn = "&flv_addr=media08.website.com/s/b9/b9cf1f95fd.flv&jpg_addr=i48.website.com/p/b9cf1f95fd4.jpg&subsEnabled=false&related=1"
$sOut = StringRegExpReplace($sIn, "(.*addr=)(.*.flv)(&.*)", "$2")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sOut = ' & $sOut & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Many tnx for both of you !

:idiot:

:gathering:

Share this post


Link to post
Share on other sites

Could you please, explain me how its working because i will need to use it a lot.

Like here, i need from this

http://website.com/play:b9cf1f95fd
to come only
b9cf1f95fd

Share this post


Link to post
Share on other sites

I think i got it

$sExtract = StringRegExpReplace($sText, ".*play:(.*)", "$1")

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Another problem

#include <IE.au3>
Local $url = "http://vbox7.com/etc/ext.do?key=b9cf1f95fd&antiCacheStamp=1343505339091"
Local $oIE = _IECreate ($URL, 0, 0, 1, 0)
Local $sHTML = _IEBodyReadHTML($oIE)
Local $sExtract2 = StringRegExpReplace($sHTML, ".*addr=(.*)&jpg_addr=.*", "$1")
MsgBox(0, "Extract", $sExtract2 )

$sExtract2 isnt working :(

Edited by horne

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

horne,

It does not work because the 2 strings are not exactly the same:

what you gave us

&flv_addr=media08.website.com/s/b9/b9cf1f95fd.flv&jpg_addr=i48.website.com/p/b9cf1f95fd4.jpg&subsEnabled=false&related=1
&flv_addr=media08.vbox7.com/s/b9/b9cf1f95fd.flv&jpg_addr=i48.vbox7.com/p/b9cf1f95fd4.jpg&subsEnabled=false&related=1 

what I get from the site

This works for both though when I try it:

#include <IE.au3>
Local $url = "http://vbox7.com/etc/ext.do?key=b9cf1f95fd&antiCacheStamp=1343505339091"
Local $oIE = _IECreate ($URL, 0, 0, 1, 0)
Local $sHTML = _IEBodyReadHTML($oIE)
Local $sExtract2 = StringRegExpReplace($sHTML, ".*addr=(.*flv).*", "$1")
MsgBox(0, "Extract", $sExtract2 )

$sHTML = "&flv_addr=media08.website.com/s/b9/b9cf1f95fd.flv&jpg_addr=i48.website.com/p/b9cf1f95fd4.jpg&subsEnabled=false&related=1"
Local $sExtract = StringRegExpReplace($sHTML, ".*addr=(.*flv).*", "$1")
MsgBox(0, "Extract", $sExtract)

M23

Edit: Hi UEZ - I see you got in first this time! :D

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Tnx a lot guys you are the best !

Share this post


Link to post
Share on other sites

horne,

Glad I could assist. :)

But no more PMs asking for help - OK? :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

How i can use StringRegExpReplace to catch something specific. Like here

#include <IE.au3>
Local $vboxcode = InputBox("Vbox7 downloader", "Enter vbox7 code.", "", " ")
Local $oIE = _IECreate ($vboxcode, 0, 0, 1, 0)
Local $sHTML = _IEBodyReadHTML($oIE)
Local $sExtract2 = StringRegExpReplace($sHTML, '<span class="title">(</span>)', "$1")
_IEQuit($oIE)
;###MsgBox(0, "Test", $sExtract2, 1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sExtract2 = ' & $sExtract2 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

'<span class="title">(</span>)'

I want to catch the title in the code, without the rest of the page code.

I am sure its something elementary, but i am new in this language.

Share this post


Link to post
Share on other sites

horne,

It is not AutoIt itself that causes the problem - it is creating the correct pattern for the RegEx. These little things are probably the hardest thing I have ever tried to learn in computing terms. A good place to start would be www.regular-expressions.info/tutorial.html - but it is a steep learning curve at the beginning. :)

As to your current problem, are there several "<span class="title"></span>" strings on the page or just the one? :huh:

M23

Why will this poxy editor not let me insert urls this evening? :mad:


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

its only one

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

horne,

Then try this:

Local $sExtract2 = StringRegExpReplace($sHTML, '.*<span class="(.*)"></span>.*', "$1")

The difference is that we are including all the characters before and after the <span><span> text and capturing what is between them. ;)

M23

Edited by Melba23
Wrong button too soon!

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

The easiest way to learn regex is with a tester, here is the one I use. I changed it from the one in the link so it recalculates the results as you type, so it can be slow with a large sample.

#include <GUIConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <IE.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
; Thanks to w0uter for the original GUI layout.





Global $CurrentInput, $SREMode = 0, $SREFlag = 0, $FileSaved = False,$HSRECombo,$HExtended,$HOutput,$HSRERCombo,$HSRERReplace, $HError,$HSRERCount
Global $aTime[5]
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")


main()

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
sre()
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND

Func main()
$MainGUI = GUICreate("String Regular Expression Tester", 632, 628)
$HTabMain = GUICtrlCreateTab(5, 15, 620, 200)
$hTab1 = GUICtrlCreateTabItem("Copy Expression")
$hInput1 = GUICtrlCreateEdit("", 10, 42, 608, 166)
GUICtrlSetLimit(-1, 1000000)
$CurrentInput = $hInput1
$hTab2 = GUICtrlCreateTabItem("Load file to test")
$LoadFileButton = GUICtrlCreateButton("Open", 15, 45, 60, 20)
$FileLoadedInput = GUICtrlCreateInput("", 90, 45, 528, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
$hInput2 = GUICtrlCreateEdit("", 10, 72, 608, 136)
$hTab3 = GUICtrlCreateTabItem("Get website text/HTML")
$WebTextButton = GUICtrlCreateButton("Text", 15, 45, 60, 20)
$WebHTMLButton = GUICtrlCreateButton("HTML", 85, 45, 60, 20)
$WebADDRInput = GUICtrlCreateInput("FULL ADDR HERE", 160, 45, 458, 20)
$hInput3 = GUICtrlCreateEdit("", 10, 72, 608, 136)
$hTab4 = GUICtrlCreateTabItem("Notes")
$LoadFileButton_Notes = GUICtrlCreateButton("Open", 15, 45, 60, 20)
$SaveFileButton_Notes = GUICtrlCreateButton("Save", 90, 45, 60, 20)
$FileLoadedInput_Notes = GUICtrlCreateInput("", 170, 45, 448, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
$hInput_Notes = GUICtrlCreateEdit(";;; Personal notepad to store anything you want in ;;;" & @CRLF, 10, 72, 608, 136)
$hTab5 = GUICtrlCreateTabItem("AutoIt")
$LoadFileButton_AutoIt = GUICtrlCreateButton("Open file", 15, 45, 60, 20)
$SaveFileButton_AutoIt = GUICtrlCreateButton("Save file", 90, 45, 60, 20)
$OpenInScite_AutoIt = GUICtrlCreateButton("SciTE", 165, 45, 60, 20)
$RunButton_AutoIt = GUICtrlCreateButton("Run Script", 240, 45, 60, 20)
$RegExButton_AutoIt = GUICtrlCreateButton("Generate RegEx Code", 315, 45, 120, 20)
$hInput_AutoIt = GUICtrlCreateEdit("; Open, edit or run scripts from here. Default save Location is in ScriptDirAutoItCode.au3" & @CRLF, 10, 72, 608, 136)
GUICtrlCreateTabItem("") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GUICtrlCreateGroup("Pattern", 5, 217, 620, 67)
$HSRECombo = GUICtrlCreateInput("(.*)", 84, 235, 527, 32)
GUICtrlSetFont(-1, 14, 400, 0, "MS Reference Sans Serif")
GUICtrlSendMsg(-1, $CB_SETEDITSEL, 0, 0)
$ButtonTest = GUICtrlCreateButton("Copy", 18, 237, 55, 27, 0)
$HSRERCombo = GUICtrlCreateInput("(.*)", 84, 235, 367, 32)
GUICtrlSetFont(-1, 14, 400, 0, "MS Reference Sans Serif")
GUICtrlSendMsg(-1, $CB_SETEDITSEL, 0, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$HSRERReplace = GUICtrlCreateInput("", 455, 235, 100, 32)
GUICtrlSetFont(-1, 14, 400, 0, "MS Reference Sans Serif")
GUICtrlSendMsg(-1, $CB_SETEDITSEL, 0, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$HSRERCount = GUICtrlCreateInput("0", 565, 235, 50, 32)
GUICtrlSetFont(-1, 14, 400, 0, "MS Reference Sans Serif")
GUICtrlSendMsg(-1, $CB_SETEDITSEL, 0, 0)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Type", 5, 292, 125, 73)
$HRadioSRE = GUICtrlCreateRadio("StringRegEx", 10, 308, 82, 23)
GUICtrlSetState(-1, $GUI_CHECKED)
$HRadioSRER = GUICtrlCreateRadio("RegExpReplace", 10, 331, 96, 23)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Flag", 5, 370, 125, 138)
$HRadioF0 = GUICtrlCreateRadio("0: True/False", 10, 388, 82, 23)
GUICtrlSetTip(-1, "Returns 1 (matched) or 0 (no match).")
GUICtrlSetState(-1, $GUI_CHECKED)
$HRadioF1 = GUICtrlCreateRadio("1: Array of matches", 10, 411, 112, 23)
GUICtrlSetTip(-1, "Return array of matches.")
$HRadioF2 = GUICtrlCreateRadio("2: Array (Perl / PHP)", 10, 433, 112, 23)
GUICtrlSetTip(-1, "Return array of matches including the full match (Perl / PHP style)..")
$HRadioF3 = GUICtrlCreateRadio("3: Global matches", 10, 455, 112, 23)
GUICtrlSetTip(-1, "Return array of global matches.")
$HRadioF4 = GUICtrlCreateRadio("4: A/A (Perl / PHP)", 10, 477, 112, 23)
GUICtrlSetTip(-1, "Return an array of arrays containing global matches including the full match (Perl / PHP style).")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$HOutput = GUICtrlCreateEdit("", 135, 284, 490, 339)
$Group4 = GUICtrlCreateGroup("Return Values", 5, 514, 125, 68)
$Label1 = GUICtrlCreateLabel("@Error", 13, 532, 37, 17)
GUICtrlSetColor(-1, 0x3399FF)
$Label2 = GUICtrlCreateLabel("@Extended", 58, 532, 60, 17)
GUICtrlSetColor(-1, 0x3399FF)
$HError = GUICtrlCreateInput("", 13, 552, 37, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$HExtended = GUICtrlCreateInput("", 62, 552, 52, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ButtonHelp = GUICtrlCreateButton("Help!", 10, 591, 112, 30, 0)
GUISetState(@SW_SHOW)


While 1
Sleep(20)
If $FileSaved = True And WinActive($MainGUI) = 1 Then
$aTime2 = FileGetTime(@ScriptDir & 'AutoItCode.au3')
$iDateCalc = _DateDiff('s', $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & " " & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5], $aTime2[0] & "/" & $aTime2[1] & "/" & $aTime2[2] & " " & $aTime2[3] & ":" & $aTime2[4] & ":" & $aTime2[5])
If $iDateCalc >= 1 Then
GUICtrlSetData($hInput_AutoIt, FileRead(@ScriptDir & 'AutoItCode.au3'))
$FileSaved = False
Else
$FileSaved = False
EndIf
EndIf

$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $LoadFileButton
$Address = FileOpenDialog("Open a file to test", @WorkingDir, "Text Related (*.*)")
If @error <> 1 Then GUICtrlSetData($hInput2, FileRead($Address))
GUICtrlSetData($FileLoadedInput, $Address)
Case $LoadFileButton_Notes
$Address = FileOpenDialog("Open a file to test", @WorkingDir, "Text Related (*.*)")
If @error <> 1 Then GUICtrlSetData($hInput_Notes, FileRead($Address))
GUICtrlSetData($FileLoadedInput_Notes, $Address)
Case $SaveFileButton_Notes
$Address = FileSaveDialog("Save Notes", @WorkingDir, "Text (*.txt)", 16)
If StringRight($Address, 4) <> ".txt" Then $Address &= ".txt"
FileDelete($Address)
FileWrite($Address, GUICtrlRead($hInput_Notes))
Case $LoadFileButton_AutoIt
$Address = FileOpenDialog("Open a file to test", @WorkingDir, "Text Related (*.*)")
If @error <> 1 Then GUICtrlSetData($hInput_AutoIt, FileRead($Address))
Case $SaveFileButton_AutoIt
$Address = FileSaveDialog("Save Script", @WorkingDir, "Au3 (*.au3)", 16)
If StringRight($Address, 4) <> ".au3" Then $Address &= ".au3"
FileDelete($Address)
FileWrite($Address, GUICtrlRead($hInput_AutoIt))
Case $OpenInScite_AutoIt
FileDelete(@ScriptDir & 'AutoItCode.au3')
FileWrite(@ScriptDir & 'AutoItCode.au3', GUICtrlRead($hInput_AutoIt))
ShellExecute(@ScriptDir & 'AutoItCode.au3', "", "", "Open")
$aTime = FileGetTime(@ScriptDir & 'AutoItCode.au3')
$FileSaved = True
Sleep(1000)
Case $RunButton_AutoIt
FileDelete(@ScriptDir & 'AutoItCode.au3')
FileWrite(@ScriptDir & 'AutoItCode.au3', GUICtrlRead($hInput_AutoIt))
ShellExecute(@ScriptDir & 'AutoItCode.au3', "", "", "Run")
Case $RegExButton_AutoIt
If $SREMode = 0 Then
$sPattern = GUICtrlRead($HSRECombo)
GUICtrlSetData($HOutput, "StringRegExp($Value, " & '"' & $sPattern & '"' & ", " & $SREFlag & ")")
Else
$sPattern = GUICtrlRead($HSRERCombo)
$sReplace = GUICtrlRead($HSRERReplace)
$iCount = GUICtrlRead($HSRERCount)
GUICtrlSetData($HOutput, "StringRegExpReplace($Value, " & '"' & $sPattern & '"' & ", " & '"' & $sReplace & '"' & ", " & $iCount & ")")
EndIf


Case $HTabMain
If GUICtrlRead($HTabMain) = 0 Then
$CurrentInput = $hInput1
ElseIf GUICtrlRead($HTabMain) = 1 Then
$CurrentInput = $hInput2
ElseIf GUICtrlRead($HTabMain) = 2 Then
$CurrentInput = $hInput3
GUICtrlSetState($WebADDRInput, $GUI_FOCUS)
GUICtrlSendMsg($WebADDRInput, $EM_SETSEL, 0, 1000)
EndIf

Case $HRadioSRE
$SREMode = 0
GUICtrlSetState($HRadioF0, $GUI_ENABLE)
GUICtrlSetState($HRadioF1, $GUI_ENABLE)
GUICtrlSetState($HRadioF2, $GUI_ENABLE)
GUICtrlSetState($HRadioF3, $GUI_ENABLE)
GUICtrlSetState($HRadioF4, $GUI_ENABLE)
GUICtrlSetState($HSRERCombo, $GUI_HIDE)
GUICtrlSetState($HSRERReplace, $GUI_HIDE)
GUICtrlSetState($HSRECombo, $GUI_SHOW)
GUICtrlSetState($HSRERCount, $GUI_HIDE)
Case $HRadioSRER
$SREMode = 1
GUICtrlSetState($HRadioF0, $GUI_DISABLE)
GUICtrlSetState($HRadioF1, $GUI_DISABLE)
GUICtrlSetState($HRadioF2, $GUI_DISABLE)
GUICtrlSetState($HRadioF3, $GUI_DISABLE)
GUICtrlSetState($HRadioF4, $GUI_DISABLE)
GUICtrlSetState($HSRECombo, $GUI_HIDE)
GUICtrlSetState($HSRERCombo, $GUI_SHOW)
GUICtrlSetState($HSRERReplace, $GUI_SHOW)
GUICtrlSetState($HSRERCount, $GUI_SHOW)
Case $HRadioF0
$SREFlag = 0
Case $HRadioF1
$SREFlag = 1
Case $HRadioF2
$SREFlag = 2
Case $HRadioF3
$SREFlag = 3
Case $HRadioF4
$SREFlag = 4
Case $ButtonTest
SRE(True)
Case $ButtonHelp
$helppath = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "", 0, -1))
Run($helppath & "Autoit3Help.exe StringRegExp")
If @error = 1 Then MsgBox(0, "Error", "Cannot find help file")
Case $WebTextButton
_IELoadWaitTimeout(30000)
GUICtrlSetData($hInput3, "Please wait...")
$oIE = _IECreate(GUICtrlRead($WebADDRInput), 0, 0)
If @error = 6 Then
GUICtrlSetData($hInput3, "Load Timeout")
Else
GUICtrlSetData($hInput3, _IEBodyReadText($oIE))
EndIf
_IEQuit($oIE)
Case $WebHTMLButton
_IELoadWaitTimeout(30000)
GUICtrlSetData($hInput3, "Please wait...")
$oIE = _IECreate(GUICtrlRead($WebADDRInput), 0, 0)
If @error = 6 Then
GUICtrlSetData($hInput3, "Load Timeout")
Else
GUICtrlSetData($hInput3, _IEBodyReadHTML($oIE))
EndIf
_IEQuit($oIE)

EndSwitch
WEnd

EndFunc ;==>Main
Func SRE($xCopy=False)


If $SREMode = 0 Then
$sText = GUICtrlRead($CurrentInput)
$sPattern = GUICtrlRead($HSRECombo)
If $xCopy=True Then ClipPut("StringRegExp($sText , '"& $sPattern&"' , "& $SREFlag&")")
$Regex = StringRegExp($sText, $sPattern, $SREFlag)
$iError = @error
$iExt = @extended
GUICtrlSetData($HError, $iError)
GUICtrlSetData($HExtended, $iExt)



If $SREFlag <= 3 Then
$RegExSize = UBound($Regex)
If @error = 1 Then
GUICtrlSetData($HOutput, $Regex)
Else

$OutputString = ""
For $I = 0 To $RegExSize - 1
$OutputString &= "[" & $I & "] = " & $Regex[$I] & @CRLF
Next

GUICtrlSetData($HOutput, $OutputString)
EndIf

Else
$OutputString = ""
For $I = 0 To UBound($Regex) - 1
$match = $Regex[$I]
For $J = 0 To UBound($match) - 1
$OutputString &= "[" & $I & "," & $J & "] = " & $match[$J] & @CRLF
Next
Next
GUICtrlSetData($HOutput, $OutputString)

EndIf

If $iError = 2 Then
GUICtrlSetData($HOutput, "Error in pattern. Character: " & $iExt - 2)


EndIf


ElseIf $SREMode = 1 Then


$sText = GUICtrlRead($CurrentInput)
$sPattern = GUICtrlRead($HSRERCombo)
$sReplace = GUICtrlRead($HSRERReplace)
$iCount = GUICtrlRead($HSRERCount)
If $xCopy=True Then ClipPut("StringRegExpReplace( $sText , '"& $sPattern&"' , '"& $sReplace&"' , "& $iCount&")")
$sRegExR = StringRegExpReplace($sText, $sPattern, $sReplace, $iCount)
$iError = @error
$iExt = @extended


GUICtrlSetData($HError, $iError)
GUICtrlSetData($HExtended, $iExt)
GUICtrlSetData($HOutput, $sRegExR)

If $iError = 2 Then
GUICtrlSetData($HOutput, "Error in pattern. Character: " & $iExt - 2)

EndIf


EndIf


EndFunc ;==>SRE
Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

horne,

Then try this:

Local $sExtract2 = StringRegExpReplace($sHTML, '.*<span class="(.*)"></span>.*', "$1")

The difference is that we are including all the characters before and after the <span><span> text and capturing what is between them. ;)

M23

Isnt working :( i tryed this

#include <IE.au3>
Local $vboxcode = InputBox("Vbox7 downloader", "Enter vbox7 code.", "", " ")
Local $oIE = _IECreate ($vboxcode, 0, 0, 1, 0)
Local $sHTML = _IEBodyReadHTML($oIE)
Local $sExtract2 = StringRegExpReplace($sHTML, '.*<span class="title">(.*)</span>.*', "$1")
_IEQuit($oIE)
;###MsgBox(0, "Test", $sExtract2, 1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sExtract2 = ' & $sExtract2 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

and it seems to give me anything but that i need :(

Edited by horne

Share this post


Link to post
Share on other sites

horne,

Then I suggest you post an example of the code you get in $sHTML so that we can work on the whole thing instead of a short extract. RegEx patterns are hard enough to develop when you do have all the info - trying to do it as we are is almost bound to fail. :)

M12


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Run the script and input this http://vbox7.com/play:f3632ca681

i get all the HTML of the page without the title i want and i want only the text in the title span :(

.*<span class="title">(.*)</span>.*
Edited by horne

Share this post


Link to post
Share on other sites

horne,

This gives me "top-avt-new" as the extract:

#include <IE.au3>

Local $vboxcode = InputBox("Vbox7 downloader", "Enter vbox7 code.", "", " ")
Local $oIE = _IECreate ($vboxcode, 0, 0, 1, 0)
Local $sHTML = _IEBodyReadHTML($oIE)
$aExtract = StringRegExp($sHTML, '(?U)<span class="(.*)"></span>', 3)
MsgBox(0, "Extract", $aExtract[0])

Is that what you wanted? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  
Followers 0