Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/10/2023 in all areas

  1. I would help if you could provide some basic code, especially the arrays definition. I don't care if it is hard-coded, I just don't want to create those arrays manually from scratch.
    2 points
  2. water

    AD - Active Directory UDF

    Version 1.6.3.0

    17,278 downloads

    Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    1 point
  3. Well I need to check. The issue is not all our clients use KeePass, and we are in similar domain, so ideally we can’t use it. Still I’ll check with my project head if we can integrate it
    1 point
  4. Yes - you can build this into the compile flow in Scite. Here is an example that we use #AutoIt3Wrapper_Run_After=c:\Windows\signtool.exe sign /sha1 <Your Certificate HASH> /t http://timestamp.comodoca.com "%out%" Hope this helps
    1 point
  5. Very true, thanks for this correct explanation which concerns the pipe symbol, because I applied it wrongly to only 1 character at its left. Another example (without spaces !) to confirm that behavior : Input : a1b2c3b2de Pattern : (b)(?=2c|d) Replace pattern : <$1> Result : a1<b>2c3b2de Capturing group (b) ... only if b is immediately followed by (2 AND c) OR d So only 1 b is correctly captured, when 2 b's would have been captured when using my wrong explanation "2 AND (c OR d)" which in fact corresponds to this pattern (b)(?=2(?:c|d)) For the record, I just made a new change in "RegExpQuickTester.au3" (bringing it to version 2.5e) to get rid of any disturbing superfluous @CRLF that could be found at the end of the read-only Result Edit field. I mean... we always take care of trailing spaces and last @CRLF's in all these edit fields (input string, search pattern, replace pattern, result prefix) so why shouldn't we in the Result field ? It's not because the original scripter added lines that all end with @CRLF in the Result Edit field (years ago) that it should stay like this forever. As you see in the pic above, the blinking caret (visible on purpose at the exact moment the pic was taken) is placed at the very end of the result string. Typing "key down" won't do anything at this point as there are no superfluous @CRLF anymore in this read-only result field. Keeping an eventual @CRLF confused me sometimes (in RegEx modes 1 to 4) when dealing with patterns that return trailing spaces and/or trailing @CRLF's This little inconvenience never happens with leading spaces / leading @CRLF's as they're clearly visible before the matched result
    1 point
  6. Nice analysis ! Hmm I prefer told like this (parenthesis...) ... only if they're followed by (a whitespace char AND a non-whitespace char) OR (if the end of string is reached) Ha. As often I was a bit lazy and didn't take care of a possible trailing newline So there are 2 answers, keeping the lazy "+" $out = StringRegExpReplace($in, '(?<=\S)(\s+?)(?=\s\S|\z)', "") $out = StringRegExpReplace($in, '(*CR)(?<=\S)(\s+?)(?=\s\S|$)', "") But (\s+) is the best one indeed, I forgot the ability of the regex engine to look backwards - so the \s in the lookahead is not matched in the group
    1 point
  7. @mikell I grouped in the following script the 3 ways we did it (Nine, you, me) then I'll ask a question at the end of this post Local $sInput = ' AA B C D ' ; expected result : ' AA B C D' (e.g. white spaces : keep all leading, remove all trailing, no doubling between words) ;============================================================================= ; Pixelsearch's way : Local $sPattern = '(\s*)(.*\S)' Local $aOutPut = StringRegExp($sInput, $sPattern, 3) ; 3 = array of global matches Local $sOutPut = $aOutPut[0] & StringStripWS($aOutPut[1], 4) ; 4 = strip double (or more) spaces between words ConsoleWrite("Pixel" & @TAB & "<" & $sOutPut & ">" & @crlf) ; delimiters < > during debug phase ;============================================================================= ; Nine's way : Local $sOutPut = StringStripWS(StringRegExpReplace($sInput, "(\S+)(\s*)", "$1 "), 2) ; Nine's original (variable names reworked for the script) ConsoleWrite("Nine" & @TAB & "<" & $sOutPut & ">" & @crlf) ;============================================================================= ; Mikell's way : Local $sOutPut = StringRegExpReplace($sInput, '(?<=\S)(\s+?)(?=\s\S|$)', "") ; Mikell's original (variable names reworked for the script) ConsoleWrite("Mikell" & @TAB & "<" & $sOutPut & ">" & @crlf) ;============================================================================= #cs Personal notes : mikell's way is a good way to learn RegEx Assertions, as described in AutoIt help file, topic StringRegExp : "Assertions : test the character(s) preceding (look-behind), at (word boundary) or following (look-ahead) the current matching point." Note: the following input (with additional @crlf and spaces) won't give the same result when using Mikell's original pattern (why ?) Local $sInput = ' AA B C D ' & @crlf ; & ' ' & @crlf #ce Console output is the same for the 3 of us : Pixel   <       AA B C D> Nine    <       AA B C D> Mikell  <       AA B C D> Your way is interesting because it teaches us Regex “lookaround” expressions, as described in AutoIt helpfile, topic Regex, for example the Positive look-behind and Positive look-ahead found in your pattern : (?<=\S)(\s+?)(?=\s\S|$) (?<=X) Positive look-behind: matches when the subpattern X matches characters preceding the current position. [...] (?=X) Positive look-ahead: matches when the subpattern X matches starting at the current position. I tried your pattern with "RegExpQuickTester.au3", explanations will follow : Nice explanation (directly in RegExpQuickTester right click help menu) for the 4 lookaround expressions, it helped me a lot to understand your pattern Now if I understood correctly, we're searching for : Whitespace character(s) in the capturing group (\s+?) ... only if they're preceded by a non-whitespace char, because of the Positive look-behind (?<=\S) ... only if they're followed by a whitespace char AND (a non-whitespace char OR if the end of string is reached), because of the Positive look-ahead (?=\s\S|$) In the precedent pic, the Replace Pattern Tab is green (thanks TCM_HIGHLIGHTITEM !) . This indicates that there is something typed in the edit control found in the Replace Pattern Tab. I typed <$1> in it, so we can see exactly the 3 groups that matched your pattern in the Result field (at the bottom of the pic) and everything seems correct. A question now : how should your pattern be modified so it gives a correct result with this $sInput code : Local $sInput = '       AA     B C      D       ' & @crlf   ; & '   ' & @crlf If we run the preceding script with this input line, then it outputs like this in the console : Pixel   <       AA B C D> Nine    <       AA B C D> Mikell  <       AA B C D > Nine's way (and mine) output correctly, so how should your pattern be amended to output correctly too ? Thanks Edit: maybe this is the answer to my question. Mikell's original group is scripted like this, with a lazy ? that inverts the greediness (why was the laziness required ?) (\s+?) When I try it without the question mark, then the greediness reappears and grabs everything at the end of the input string, including @CRLF and additional whitespaces. Also, the following greedy pattern seems to work fine when applied to the original input line : (\s+)
    1 point
  8. A simple SRER does the job $in = ' AA B C D ' $out = StringRegExpReplace($in, '(?<=\S)(\s+?)(?=\s\S|$)', "") msgbox(0,"", "=" & $out & "=")
    1 point
  9. Or this single liner ? Local $sString = StringStripWS(StringRegExpReplace(" A B C D ", "(\S+)(\s*)", "$1 "), 2) ConsoleWrite($sString & @CRLF)
    1 point
  10. Hi everybody Why not a RegEx pattern with 2 capturing groups ? Local $sInput = ' AB C D ' Local $sPattern = '(\s*)(.*\S)' Local $aOutPut = StringRegExp($sInput, $sPattern, 3) ; 3 = array of global matches Local $sOutPut = $aOutPut[0] & StringStripWS($aOutPut[1], 4) ; 4 = strip double (or more) spaces between words ; ConsoleWrite($sOutPut & @crlf) ConsoleWrite(">" & $sOutPut & "<" & @crlf) ; line with delimiters during debug phase
    1 point
  11. I found a solution!!! I use this and it works!!! I thought I tried this. I must have typed something slightly wrong. $oExcel.ActiveSheet.Range("A1").select $oExcel.ActiveSheet.Paste
    1 point
  12. BasementDweller, _ArrayFindAll returns an array - _ArrayDelete requires a delimited string as a range. Therein lies your problem. Convert the array into string using _ArrayToString and setting the $sDelim_Col parameter to ";" will give you a formatted string that _ArrayDelete will accept: #include <Array.au3> Global $aArray[20] For $i = 0 To 19 $aArray[$i] = Random(1, 5, 1) Next _ArrayDisplay($aArray) $vRange =_ArrayFindAll($aArray, "2", Default, Default, Default, Default, 0) _ArrayDisplay ($vRange) $vRange = _ArrayToString($vRange, ";") ConsoleWrite($vRange & @CRLF) _ArrayDelete($aArray, $vRange) _ArrayDisplay($aArray) M23
    1 point
  13. @PunkoHead Here are the constants for the Option property of the WinHttpRequest object: Global Enum $WinHttpRequestOption_UserAgentString, _ $WinHttpRequestOption_URL, _ $WinHttpRequestOption_URLCodePage, _ $WinHttpRequestOption_EscapePercentInURL, _ $WinHttpRequestOption_SslErrorIgnoreFlags, _ $WinHttpRequestOption_SelectCertificate, _ $WinHttpRequestOption_EnableRedirects, _ $WinHttpRequestOption_UrlEscapeDisable, _ $WinHttpRequestOption_UrlEscapeDisableQuery, _ $WinHttpRequestOption_SecureProtocols, _ $WinHttpRequestOption_EnableTracing, _ $WinHttpRequestOption_RevertImpersonationOverSsl, _ $WinHttpRequestOption_EnableHttpsToHttpRedirects, _ $WinHttpRequestOption_EnablePassportAuthentication, _ $WinHttpRequestOption_MaxAutomaticRedirects, _ $WinHttpRequestOption_MaxResponseHeaderSize, _ $WinHttpRequestOption_MaxResponseDrainSize, _ $WinHttpRequestOption_EnableHttp1_1, _ $WinHttpRequestOption_EnableCertificateRevocationCheck Here are the valid values for ignoring SSL errors Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_UnknownCA = 0x0100 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_CertWrongUsage = 0x0200 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_CertCNInvalid = 0x1000 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_CertDateInvalid = 0x2000 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_IgnoreAll = 0x3300 ;IGNORE ALL OF THE ABOVE So to ignore all SSL errors, you could add the following line before your send: $oHTTP.Option($WinHttpRequestOption_SslErrorIgnoreFlags) = $WinHttpRequestOption_SslErrorIgnoreFlags_IgnoreAll or $oHTTP.Option(4) = 0x3300
    1 point
  14. Siryx, F.Y.I. Please see comments in code... #include <File.au3> #include <Array.au3> $file = "D:\Dokumente\Tracklist.txt" #cs FileOpen($file, 0) ; this stmt has no effect because there is no variable assigned to contain the file handle ; the stmt would normally be written as "local $hfl = fileopen($file,0)" Global $arr[1000] ReDim $arr[_FileCountLines($file)+1] ; these two stmt could have been expressed as "Global $arr[_FileCountLines($file)+1]" For $i = 1 to _FileCountLines($file) ; _FileCountLines again, start of performance issues...should be ubound($arr) - 1 $line = FileReadLine($file, $i) ; performance hog - each FileReadLine causes an open/close sequence when using a file name, as opposed to a file handle $arr[$i] = $line Next #ce local $arr = stringsplit(fileread($file),@CRLF,3) ; read the entire file and split on EOL chars creating array $arr ; this assumes @CRLF as the EOL sequence. The last parm of stringsplit ("3") means ; use the entire delimiter string as the split criteria and do NOT return a count of lines in offset 0 ; I might have written the above nested expression as: ; local $sFile = fileread($file) ; local $arr = stringsplit($sFile,@CRLF,3) _ArraySort($arr) _ArrayDisplay($arr)kylomas
    1 point
×
×
  • Create New...