Sign in to follow this  
Followers 0
motosingh

how will be easiest way to parse

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$atest = StringRegExp ( $test, "encr-key=([a-z|A-Z|0-9]{0,})", 3 )

Edited 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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0