-
Notifications
You must be signed in to change notification settings - Fork 0
/
Regular Expression autoit
95 lines (78 loc) · 3.12 KB
/
Regular Expression autoit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <File.au3>
#include <Array.au3>
#include "RecFileListToArray.au3"
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
;$aArray = _RecFileListToArray(@WorkingDir, "*.html;*.htm;*.txt;*.css;*.js", 1, 1, 0)
$aArray = _RecFileListToArray(@WorkingDir, "*.html;*.htm;*.css", 1, 0, 0)
$linenum = 0
$varNumPregunta = 1
Local $hFileOpen = FileOpen(@ScriptDir & "\Data\allquestions.html", $FO_APPEND)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file." & $hFileOpen & "route " & @ScriptDir & "\Data\qselect.txt")
EndIf
For $files In $aArray
ConsoleWrite("FILE: " & $files & @CRLF)
$file = FileOpen($files, 0)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file." & $file)
Else
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
$linenum = $linenum + 1
;~ $findlinea = StringRegExp($line, '(?s).*?(' & $linestringdel & ').*?', 0, 1)
$findlinea = StringRegExp($line, '(?s)\Q' & '<form id="questionForm" action="https://www.upwork.com' & '\E')
If $findlinea = 1 Then
FileWrite($hFileOpen, $line & @CRLF)
FileWrite($hFileOpen, '<b>Question ' & $varNumPregunta & '</b>' & @CRLF)
$varNumPregunta = $varNumPregunta + 1
$line = FileReadLine($file)
While 1
$findcheckbox = StringRegExp($line, '(?s)\Q' & '<input type="checkbox"' & '\E')
If $findcheckbox = 1 Then
;Busca cambiar los checkbox y asignar la letra
$strLetterLeft = 'name="answers['
$strLetterRight = ']"'
$findletter = StringRegExp($line, '\Q' & $strLetterLeft & '\E' & "(.*?)" & '\Q' & $strLetterRight & '\E' , 3, 1)
For $i = 0 To UBound($findletter) - 1
$stringrep2 = StringRegExpReplace($line, '<([^%]*?).*', '<b>' & StringUpper($findletter[0]) & '.</b> ')
$strAnswerLeft = '<pre class="np">'
$strAnswerRight = '</pre>'
$findanswer = StringRegExp($line, $strAnswerLeft & "(.*?)" & $strAnswerRight , 3, 1)
If IsArray($findanswer) Then
$varStringFinal = $stringrep2 & '<pre style="display: inline" class="np">' & $findanswer[0] & '</pre>'
$line = $varStringFinal
Else
$strAnswerLeft = '<pre class="np">'
$findanswer = StringRegExp($line, $strAnswerLeft & "(.*)", 3, 1)
If IsArray($findanswer) Then
$varStringFinal = $stringrep2 & '<pre style="display: inline" class="np">' & $findanswer[0]
$line = $varStringFinal
EndIf
EndIf
Next
EndIf
FileWrite($hFileOpen, $line & @CRLF)
$line = FileReadLine($file)
If @error = -1 Then
ConsoleWrite("Must not be activated check!")
ExitLoop
EndIf
$findlineaend = StringRegExp($line, '(?s)\Q' & '</fieldset>' & '\E')
If $findlineaend = 1 Then
FileWrite($hFileOpen, $line & @CRLF)
;FileWrite($hFileOpen, '<b>ANSWER: </b>'& @CRLF &'</form>' & @CRLF)
FileWrite($hFileOpen, '<i>ANSWER: </i>'& @CRLF &'</form>' & @CRLF)
;FileWrite($hFileOpen, '<pre>ANSWER: </pre>'& @CRLF &'</form>' & @CRLF)
ExitLoop
EndIf
WEnd
EndIf
WEnd
FileClose($file)
$linenum = 0
EndIf
Next
FileClose($hFileOpen)
MsgBox(0, "showlist", "completed")