motosingh Posted June 14, 2012 Posted June 14, 2012 I have content of the txt file as below. I need to match spi=xxxxx and then pick the right encr-key how will be easiest way to scrip this. source=192.168.0.1[4500] destination=192.168.0.2[4501] protocol=esp-udp mode=tunnel spi=3273316746(0xc31ad98a) reqid=3338(0x00000d0a) encr-algo=aes-cbc encr-key=f57ab28d8c833338b62af2e6b470dce6 auth-algo=hmac-sha1 last-use=2012-06-14/14:21:46 bytes-processed=0 hard-lifebyte=0 soft-lifebyte=0 vrfid=0 xvrfid=0 Thanks.
jdelaney Posted June 14, 2012 Posted June 14, 2012 (edited) #include <Array.au3> $test = "protocol=esp-udp mode=tunnel spi=3273316746(0xc31ad98a) reqid=3338(0x00000d0a)" $atest = StringRegExp ( $test, "(?i)(?U).*spi=(.*)((.*))", 3 ) _ArrayDisplay ( $atest ) So, if you read in your whole string/doc to a variable, the above should work. Edited June 14, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Zedna Posted June 14, 2012 Posted June 14, 2012 If you are not familiar with Regular Expressions then look at _StringBetween() Resources UDF ResourcesEx UDF AutoIt Forum Search
motosingh Posted June 15, 2012 Author Posted June 15, 2012 Thanks .. I am very new to auto it so it was very helpful. #include <Array.au3> #include <File.au3> $find = InputBox('What SPI to find ', 'Type in below what to search for.' & @CRLF & _ 'Ecr key for spi will be picked', 'Enter SPI', '', 200, 140) Local $array_src _FileReadToArray('encrp.txt', $array_src) Local $iIndex = _ArraySearch($array_src, $find, 0, 0, 0, 1) ; add the index to find the encr key $iIndex+=15 ;MsgBox(64, 'Show file', $array_src[$iIndex]) $atest = StringRegExp ($array_src[$iIndex], "(?i)(?U).*encr-key=.*", 3 ) _ArrayDisplay ( $atest ) I am get the correct string but I am doing something wrong with reg express as it doesn't pick up f57ab28d8c833338b62af2e6b470dce6 from encr-key=f57ab28d8c833338b62af2e6b470dce6
jdelaney Posted June 15, 2012 Posted June 15, 2012 (edited) $atest = StringRegExp ( $test, "encr-key=([a-z|A-Z|0-9]{0,})", 3 ) Edited June 15, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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