jvanegmond Posted August 2, 2006 Share Posted August 2, 2006 I had a big script, and when it came down to working. It didn't do anything, so i threw it away and made this simple script. This is a startup to scanning a folder in all .html files for colors ("7238AB" strings) and returning them in some way. Here's the full script: #include <Array.au3> MsgBox(0, "", FileRead(@ScriptDir & "\navigatie.html" )) $Array = StringRegExp(FileRead(@ScriptDir & "\navigatie.html" ), '"\A{6}"',3) If @extended = 1 Then _ArrayDisplay($Array,"$Array") EndIf Exit And the attachment html file: github.com/jvanegmond Link to comment Share on other sites More sharing options...
/dev/null Posted August 2, 2006 Share Posted August 2, 2006 (edited) I had a big script, and when it came down to working. It didn't do anything, so i threw it away and made this simple script. This is a startup to scanning a folder in all .html files for colors ("7238AB" strings) and returning them in some way.From the help file of StringRegExp():@Extended Return value 0 (false) Match not found. Return value is "" (empty string). 1 (true) Match found. Return value is an array of all group values. If there are no groups in the pattern, the function returns "" (empty string). I can't see any groups in your pattern!CheersKurt Edited August 2, 2006 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 2, 2006 Share Posted August 2, 2006 Hi, you could do something like this $Array = StringRegExp($a, '(\A{6})',3), but that doesn't make sense to me. I would go ahead with stringbetween func. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jvanegmond Posted August 3, 2006 Author Share Posted August 3, 2006 From the help file of StringRegExp():@Extended Return value 0 (false) Match not found. Return value is "" (empty string). 1 (true) Match found. Return value is an array of all group values. If there are no groups in the pattern, the function returns "" (empty string). I can't see any groups in your pattern!CheersKurtThat's why i check for @extended.Mega, i think you mean StringMed. But that also doesn't make much sence to me.. Would i use StringInString to check for " and then use the StringMed function to get the value? github.com/jvanegmond Link to comment Share on other sites More sharing options...
/dev/null Posted August 3, 2006 Share Posted August 3, 2006 That's why i check for @extended.maybe, but your check does exactly nothing, as the function will never set @extended to 1 without a group in the pattern!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 3, 2006 Share Posted August 3, 2006 Hi, does this help? #include <Array.au3> #include <File.au3> Dim $a _FileReadToArray(@ScriptDir & "\navigatie.html", $a) ;_ArrayDisplay($a, "a") Dim $start = 'color="';target=" Dim $end = '">' Dim $array For $i = 1 To UBound($a)-1 If StringInStr($a[$i], $start) <> 0 Then $array = _SRE_Between($a[$i], $start, $end, 1) ;MsgBox(0,"",_StringBetween1($a[$i], $start, $end)) EndIf Next If IsArray($array) Then _ArrayDisplay($array, "Found") Else MsgBox(0, 'MsgBox', $array) EndIf Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0] If IsArray($a_Array) Then Return $a_Array EndFunc ; another possibility #cs Func _StringBetween1($s_String, $s_Start = 0, $s_End = 0) $s_Start = StringInStr($s_String, $s_Start) + StringLen($s_Start) Return StringMid($s_String, $s_Start, StringInStr($s_String, $s_End) - $s_Start) EndFunc ;==>_StringBetween1 #ce So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now