Jump to content
galan2015

String

Recommended Posts

galan2015

Good morning,

I'm making progress, slowly understand regular expressions. Today I started to have fun also with an array. All expressions of landing to a file. OK!

Now I have to add each line first element that will result a complete URL.

The hope in you.

Ps. Please give the command for now, trying to finally learn something;)

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Local  $oe = StringRegExp('href="/account/5086.html">', '(?i)<A class=i href="(.*?)"',3)
For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next
$oee =_ArrayDisplay($oe, "1D display")            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <------------- trza zobaczyc f1 instrukcje helpu 
$sFilePath = @ScriptDir & "\test2.txt"

; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $oe[$i], 1)

; Display the file.
ShellExecute($sFilePath)

 

Share this post


Link to post
Share on other sites
galan2015

Test.txt:

<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="/get/13131231.html">
<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">
<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Local  $oe = StringRegExp(FileRead(@ScriptDir&'/test.txt'), '(?i)<A class=i href="(.*?)"',3)
For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next
$oee =_ArrayDisplay($oe, "1D display")            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; <------------- trza zobaczyc f1 instrukcje helpu 
$sFilePath = @ScriptDir & "\test2.txt"

; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $oe[$i], 1)

; Display the file.
ShellExecute($sFilePath)

They r wroten as /get/123123.html - i would add data before them to make whole url from _IEPropertyGet($oIE, "locationurl"))

Edited by galan2015

Share this post


Link to post
Share on other sites
nitekram

Not sure if this is what you are looking for or not, as I am not sure where you are getting the correct URL...can you show us a complete URL?

 

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Local  $oe = StringRegExp(FileRead(@ScriptDir&'/test.txt'), '(?i)<A class=i href="(.*?)"',3)
_ArrayDisplay($oe, "1D display")

For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
$oe[$i] = 'newURL.' & $i & '.html'
MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next

$sFilePath = @ScriptDir & "\test2.txt"

; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $oe)

; Display the file.
ShellExecute($sFilePath)

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
iamtheky

 

$oe[$i] = 'newURL.' & $i & '.html'
 

 

If your guess is accurate, i think this should be

$oe[$i] = 'newURL.' & $oe[$i] & '.html'

 

 

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <File.au3>

Global $oe[3]

$oe[0] = stringregexp('<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="/get/13131231.html">' , '(?i)<A class=i href="(.*?)"' , 3)[0]
$oe[1] = stringregexp('<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">' , '(?i)<A class=i href="(.*?)"' , 3)[0]
$oe[2] = stringregexp('<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">' , '(?i)<A class=i href="(.*?)"' , 3)[0]

For $i = 0 To UBound($oe) - 1
;MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
$oe[$i] = 'newURL.com' & $oe[$i]
MsgBox($MB_SYSTEMMODAL, "RegExp Test with- " & 1, $oe[$i])
Next

 

Edited by boththose

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

Share this post


Link to post
Share on other sites
nitekram

I was not sure, I was j

 

If your guess is accurate, i think this should be

$oe[$i] = 'newURL.' & $oe[$i] & '.html'

That could be, but was just showing where OP would enter the new info.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
galan2015

Guys u dont understand. I want every record that "stringRegExp" had the address that is currently displayed page at $ oie

This is page what im training my skillz

 

Func ZapiszHtmlPodglad() ; Przycisk Skanuj
local $url = _IEPropertyGet($oIE, "locationurl") ; <------- http://warsaw.craigslist.pl/search/eve

FileWrite( @ScriptDir& "\test.txt", _IEBodyReadHTML($oIE))
$adresyogloszen = StringRegExp(FileRead(@ScriptDir&'/test.txt'), '(?i)<A class=i href="(.*?)"',3)

For $i = 0 To UBound($adresyogloszen) - 1
$sFilePath = @ScriptDir & "\test2.txt"
FileWrite(@ScriptDir& '\test2.txt',$url&$adresyogloszen[$i])
_FileWriteFromArray($sFilePath, $adresyogloszen, 1)
Next
EndFunc

 

Edited by galan2015

Share this post


Link to post
Share on other sites
jguinch

?

#Include <Array.au3>

$url = "http://www.myurl.com"

$sHtml = '<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="http://example.com/url.php">' & @CRLF & _
         '<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">' & @CRLF & _
         '<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">'

$sHtml = StringRegExpReplace($sHtml, '(?iU)<a class=i href="\K(?!http)', $url)
         
$aLinks = StringRegExp($sHtml, '(?iU)<a class=i href="(.+)"', 3)
_ArrayDisplay($aLinks)

 

  • Like 1

Share this post


Link to post
Share on other sites
galan2015

?

#Include <Array.au3>

$url = "http://www.myurl.com"

$sHtml = '<P class=row dataid="47" jQueryAbsolut320150502="120"><A class=i href="http://example.com/url.php">' & @CRLF & _
         '<P class=row dataid="48" jQueryAbsolut320150502="130"><A class=i href="/get/515151231.html">' & @CRLF & _
         '<P class=row dataid="49" jQueryAbsolut320150502="132"><A class=i href="/get/123123.html">'

$sHtml = StringRegExpReplace($sHtml, '(?iU)<a class=i href="\K(?!http)', $url)
         
$aLinks = StringRegExp($sHtml, '(?iU)<a class=i href="(.+)"', 3)
_ArrayDisplay($aLinks)

 

​Thank you, next question.

If the result of StringRegExp does not include search activity how can I skip the rest of tasks? I know i should use Something like that:
Func Lolo()
Local $file1= StringRegExp(FileRead($newsdata), '<DIV class=news>(.*?)</DIV></UL>',3)
If $file1 = 1 then ; He found it
For $i = 0 To UBound($file1) - 1
MsgBox(1,1,$file1[$i])
FileWrite($newsdata,$file1[$i]&@CRLF)
ElseIf $file1 = 0 then ; not found 
EndFunc ; just if Just If the program does find anything, I would like to end the function.
Endif
Endfuc
Just If the program does find anything, I would like to end the function.
 

 

Share this post


Link to post
Share on other sites
jguinch

$file1 cannot be equal to 1 because StringRegExp with option 3 ($STR_REGEXPARRAYGLOBALMATCH) returns either an array or 0 (and @error is set to 1 or 2).

You can test if $file1 is an array : If IsArray($file1) Then ..., or test if @error is set or no : If Not @error Then ...

 

Share this post


Link to post
Share on other sites
galan2015

$file1 cannot be equal to 1 because StringRegExp with option 3 ($STR_REGEXPARRAYGLOBALMATCH) returns either an array or 0 (and @error is set to 1 or 2).

You can test if $file1 is an array : If IsArray($file1) Then ..., or test if @error is set or no : If Not @error Then ...

 

​BUt i dont know how write it ;s

Share this post


Link to post
Share on other sites
jguinch

Func Lolo()
    Local $file1 = StringRegExp(FileRead($newsdata), '<DIV class=news>(.*?)</DIV></UL>',3)
    If @error Then Return ; Or If Not IsArray($file1)
    
    For $i = 0 To UBound($file1) - 1
        MsgBox(0, "", $file1[$i])
        FileWrite($newsdata,$file1[$i]&@CRLF) ; Are you sure you what to write in the same file ?
    Next
EndFunc

 

  • Like 1

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

  • Similar Content

    • lattey
      By lattey
      hi,
      i have checkboxes and each checkbox that checked, i put in array. 
      now, im stuck on how to loop the checked array and store in in one variable. what i can do now, is only write the result into a text file. 
      below is the code:
      #include <GUIConstantsEx.au3> ;~ #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <Array.au3> Global $Count = 3 Global $CheckBoxP[$Count] Global $step[$Count] global $array1[1] Global $ExitResult $hGUI = GUICreate("Summary Steps", 500, 400) GUISetFont(12, 400, "Tahoma") GUICtrlCreateLabel( "Please Select the Summary Steps for Script Check", 70, 20) GUISetFont(10, 400, "Tahoma") Global $array_Pstep[3] = ["fix2","fix1","fix3"] global $step[3] = ["2","3","4"] $Spacing = 50 For $i = 0 To UBound($array_Pstep) - 1 $CheckBoxP[$i] = GUICtrlCreateCheckbox($array_Pstep[$i], 80, $Spacing + (20 * $i), 65, 17) Next $submit = GUICtrlCreateButton("Submit",180, 280, 80, 30) $exit = GUICtrlCreateButton("Exit",180, 320, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Select case $Msg=$submit For $i = 0 To $Count - 1 If GUICtrlRead($CheckBoxP[$i]) = $GUI_CHECKED Then _ArrayAdd($array1, $step[$i]) EndIf Next Global $logfilerray = @WorkingDir & "\checkedlist.txt" FileDelete ($logfilerray) Global $readlogfile = FileOpen($logfilerray,1) for $a = 1 to UBound($array1) - 1 ;~ $var=$array1[$a] FileWriteLine($readlogfile,$array1[$a]) Next FileClose($readlogfile) Exit case $Msg=$exit $ExitResult = MsgBox(1,"Summary Step", "Continue to Exit ?") if $ExitResult = 1 Then ;ok Exit EndIf Exit EndSelect WEnd  
    • omicron
      By omicron
      How do you perform a nested loop function with a multidimensional array from 2 lists.
      for i in list1
      (open file) extract variable
          while open for i in list 2
          (open file2) extract variable
       
      var1 + var2 = (search term)

      The list sizes will more than likely consist of different lengths.
       
      What is the best approach to accomplishing this method?
             
    • omicron
      By omicron
      Hello!

      I am working on a function that I am just getting lost on. The goal is a multiple nested loop.

      Here are the steps:
      Contents of file1.txt::
      [topic] var1=Name var2=OtherName var3=SomeotheName Contents of file2.txt::
      [subTopic] top=sub1 top2=sub2 top3=sub3 The Shell I am working from::
      #include <file.au3> $file = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) msgbox(0,'','the line ' & $i & ' is ' & $line) Next FileClose($file) Understanding however that the "msgbox" needs to then become a variable. in example the following::
      $file = "c:\yourfile.txt" FileOpen($file, 0) While true( prog.exe is running && "WinName" is open) do For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ;Open File to log "current location of file 1" FileWriteLine ("filename", $i & ' is ' & $line) var = $line Next $file2 = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ; OpenFile to log "Current location of file 2" FileWriteLine ("filename", $i & ' is ' & $line) Next FileClose($file2) FileClose($file) The goal in written form is the following ::

      While in "OpenWindow"
          read from file 1 starting at line 1 until end of file.
         file 1 is a list of names to be searched.
         With $line selected, add this element to the element in file 2.
       
      The search of a variables in list 1 and list 2 differ on the amount of posts that day. (This is not a web based platform, it is a game) I need to search 2 names and take a screenshot of the out put. The sizes of the names list depend on the activity of names at the time of search.
      This loop continues until all the names from both lists have been searched. Mostly in the format of::
      File1= item
      File2= Vendor
       
      Item + Vendor  ( Capture screen, scroll) -- Not sure how to detect if I need to scroll)
       
      Thank you for your help and support!
    • nooneclose
      By nooneclose
      I need help turning this string "20180913221626" into a formatted time string.
      I need to go from this: 20180913221626
      to this: 09/13/2018 10:16 PM
      I do not always know what the date will be so I can not just use a variable I need to actually convert/format. 
      I did see an older post in the forms that was basically the same question only the other guy did not post the working code and I can not figure out how to use _AD_GetObjectProperties properly to get what I want. 
      As always any help would be appreciated. 
      Here is the code I use to find the date, but it always gives me the unformatted version. 
      ;retrieve the items object $oItem = $oOutlook.Session.GetItemFromID($aItems[1][0], Default) $oItem.GetInspector $eSentOn = $oItem.SentOn ; When was the email sent? MsgBox("", "Sent On of the email", $eSentOn) ;******************************************************************************* ; Formats the date and time from the email ;******************************************************************************* ;Local $fDatenTime = _DateTimeFormat($eSentOn, 1) ;MsgBox("", "Formatted email time", $fDatenTime) $aProperties = _AD_GetObjectProperties($eSentOn) _ArrayDisplay($aProperties, "Did the conversion work?")  
    • Skeletor
      By Skeletor
      Hi Virtual People,
      My array works perfectly fine. However, what is the best practice if the line in the array doesn't have the correct amount of columns and if I can add a placeholder?

       
      For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") Next  
×