caramen Posted January 30, 2019 Share Posted January 30, 2019 (edited) Hey all, 2 questions One with a problem of knowledge. One with how to improve myself on regexp @mikell You're welcome This is a reproducer that you can run> i want to ping 5 servers and return the response in a label. #include <Constants.au3> #include <Array.au3> $Ping1 = "escs001" Local $cDisk = Run(@ComSpec & " /c ping "&$Ping1 , @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Global $cData = "" While 1 $line = StdoutRead($cDisk) If @error Then ExitLoop $cData &= $line WEnd $cSplitedData = StringSplit ($cData,@CRLF) MsgBox(0,"",$cSplitedData[5]) $aArray = StringRegExp(''&$cSplitedData[5], '(?i)temps=(..?)', $STR_REGEXPARRAYMATCH, 1) If @error Then Exit $iOffset = @extended For $i = 0 To UBound($aArray) - 1 MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 1 - " & $i, $aArray[$i]) Next Well I am done with it but not totaly. With that regexp the return value is : 11 or 15 or 115 depend of the time response How could i do to get 11 ms or 15 ms or 115 ms?? Btw i forgo to add the return of comspec it can be: R,ponse de 10.2.0.200ÿ: octets=32 temps=12 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=1 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=13 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=12 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=25 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=20 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=112 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=1 ms TTL=126 R,ponse de 10.2.0.200ÿ: octets=32 temps=18 ms TTL=126 I know i can solve my "problem" the simplest way by adding a second label with "ms" string and I will be done. But in my long AutoIT way I prefer to learn how to arrive to my goal with the best way How to improve myself with that StringRegExp ?? Becose actually i dont realy know what i am doing by using all these parameters... How to practice it ?! Edited January 30, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
caramen Posted January 30, 2019 Author Share Posted January 30, 2019 (edited) Wait i just tryed this and it work @mikell or anyother string regexp pro can confirm it s a good syntax ? (?i)temps=(.. ms) It is frustrating to guess about not being able to make a stringregexp script without help :/ Edited January 30, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Nine Posted January 30, 2019 Share Posted January 30, 2019 probably better with "(?i)temps=(.+ ms)" as you will miss 1 and 3 digits “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
caramen Posted January 30, 2019 Author Share Posted January 30, 2019 (edited) Ah ok thank you ! @Nine I said ok without testing but after testing all my stringregexp return @error now. Anytips to improve myself anyone ? Edited January 30, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Nine Posted January 30, 2019 Share Posted January 30, 2019 4 minutes ago, caramen said: Anytips to improve myself anyone ? https://regex101.com/ Nice tool ! caramen 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
caramen Posted January 30, 2019 Author Share Posted January 30, 2019 @Nine What a biuty... You earned a thanks My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted January 30, 2019 Share Posted January 30, 2019 regex101 is awesome I posted it all the time, and you can even link an example. It looks like temps is static, and I am assuming ms is static so any of the last couple of examples is good. Does it stay as ms if its over 1000? if not I would probably target TTL as the next static term so you capture anything between and strip white space as needed. https://regex101.com/r/5z0ncw/1 $sString = "octests=32 temps=12342134233 ms TTL=126" $sRegExPattern = "temps=(.*)TTL" $aResult = StringRegExp($sString, $sRegExPattern, 1) If IsArray($aResult) Then $sFinalResult = StringStripWS($aResult[0], 8) MsgBox(0, "", $sFinalResult) EndIf 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