Boucle sur valeur d'une Regex
Posté : lun. 22 mai 2017 14:30
Bonjour à tous,
Je ne comprends pas du tout cette erreur, le résultat de ma regex est validée, elle me retourne bien une valeur nombre.
Et lorsque je fais une boucle For $x = 1 To [la valeur de la regex] il me retourne une erreur...
ConsoleWrite($Categories[$j] & ";" & $Villes[$i] & ";page-" & $aNbPages[$x] & @TAB & $aNbPages[0] & @LF)
ConsoleWrite($Categories[$j] & ";" & $Villes[$i] & ";page-" & ^ ERROR
Func File_Pos()
Local $File_Categories = @WorkingDir & "\Categories.txt", $File_Infra = @WorkingDir & "\Villes.txt"
Local $Infra = Null, $Categories = Null
_FileReadToArray($File_Infra, $Infra)
If @error Then Exit
_FileReadToArray($File_Categories, $Categories)
If @error Then Exit
For $i = 1 To UBound($Infra) - 1
For $j = 1 To UBound($Categories) - 1
$Contenu = _INetGetSource($Categories[$j] & "/" & $Infra[$i] & "/")
$aNbResultats = StringRegExp($Contenu, '(?i)<span class="count">(\d*)</span>', $STR_REGEXPARRAYMATCH)
If @error = 0 Then
If $aNbResultats[0] = 0 Then Return False
ConsoleWrite("Number of results : " & $aNbResultats[0] & @LF) ; IT WORKS
$aNbPages = StringRegExp($Contenu, '(?i)"pageToc"(?:.*?)(\d+)<', $STR_REGEXPARRAYMATCH)
If @error = 0 Then
ConsoleWrite("Number of results : " & $aNbPages[0] & @LF) ; IT WORKS
For $x = 1 To $aNbPages[0]
ConsoleWrite($Categories[$j] & ";" & $Infra[$i] & "/page-" & $aNbPages[$x] & @TAB & $aNbPages[0] & @LF)
Next
EndIf
EndIf
Next
Next
EndFunc
Je ne comprends pas du tout cette erreur, le résultat de ma regex est validée, elle me retourne bien une valeur nombre.
Et lorsque je fais une boucle For $x = 1 To [la valeur de la regex] il me retourne une erreur...
ConsoleWrite($Categories[$j] & ";" & $Villes[$i] & ";page-" & $aNbPages[$x] & @TAB & $aNbPages[0] & @LF)
ConsoleWrite($Categories[$j] & ";" & $Villes[$i] & ";page-" & ^ ERROR
Func File_Pos()
Local $File_Categories = @WorkingDir & "\Categories.txt", $File_Infra = @WorkingDir & "\Villes.txt"
Local $Infra = Null, $Categories = Null
_FileReadToArray($File_Infra, $Infra)
If @error Then Exit
_FileReadToArray($File_Categories, $Categories)
If @error Then Exit
For $i = 1 To UBound($Infra) - 1
For $j = 1 To UBound($Categories) - 1
$Contenu = _INetGetSource($Categories[$j] & "/" & $Infra[$i] & "/")
$aNbResultats = StringRegExp($Contenu, '(?i)<span class="count">(\d*)</span>', $STR_REGEXPARRAYMATCH)
If @error = 0 Then
If $aNbResultats[0] = 0 Then Return False
ConsoleWrite("Number of results : " & $aNbResultats[0] & @LF) ; IT WORKS
$aNbPages = StringRegExp($Contenu, '(?i)"pageToc"(?:.*?)(\d+)<', $STR_REGEXPARRAYMATCH)
If @error = 0 Then
ConsoleWrite("Number of results : " & $aNbPages[0] & @LF) ; IT WORKS
For $x = 1 To $aNbPages[0]
ConsoleWrite($Categories[$j] & ";" & $Infra[$i] & "/page-" & $aNbPages[$x] & @TAB & $aNbPages[0] & @LF)
Next
EndIf
EndIf
Next
Next
EndFunc