HezzelQuartz Posted June 19, 2023 Share Posted June 19, 2023 How to search hex sequence containing unknown sequence? For Example: 11223344 55667788 XXXXXXXX 99AABBCC DDEEFF00 XXXXXXXX = Hex Sequence that always change How to search 11223344 55667788 XXXXXXXX 99AABBCC DDEEFF00 without specifying XXXXXXXX? Thank You Link to comment Share on other sites More sharing options...
Andreik Posted June 19, 2023 Share Posted June 19, 2023 First of all you posted in the wrong section of the forum and your question is not clear at all. Search for what? As I can see all the numbers above could be valid hex sequences. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 19, 2023 Moderators Share Posted June 19, 2023 (edited) Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Edited June 19, 2023 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 19, 2023 Moderators Share Posted June 19, 2023 The topic has been moved to a more appropriate spot. @HezzelQuartz, as Andreik mentions, you haven't provided enough information. You state the section will always change, will it always be in the same place (third octet in your example)? Or will that change too? Are you looking to validate that section against some other data, or just return what that section contains? Help us help you "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
HezzelQuartz Posted June 20, 2023 Author Share Posted June 20, 2023 @JLogan3o13@Andreik Hi, I'm really sorry for posting in the wrong section. About my question, it will always be in the same place (third octet), just need to search the sequence position, not comparing against other data. So, I just want to know, where the combination exist in a large hex sequence Link to comment Share on other sites More sharing options...
Andreik Posted June 20, 2023 Share Posted June 20, 2023 Something like that? $sData = '11223344 55667788 01020304 99AABBCC DDEEFF00' $aMatches = StringRegExp($sData, '([0-9a-fA-F]{8})', 3) ConsoleWrite($aMatches[2] & @CRLF) ; Match 3rd group When the words fail... music speaks. Link to comment Share on other sites More sharing options...
HezzelQuartz Posted June 20, 2023 Author Share Posted June 20, 2023 @Andreik But, in this case, I don't know what is XXXXXXXX and cannot determine what is XXXXXXXX So, I need the search to find the first, second, fourth, fifth octet in order, whatever the third octet (XXXXXXXX) is not a problem For Example, the search can find these two sequence below 11223344 55667788 "66AA66BB" 99AABBCC DDEEFF00 11223344 55667788 "99CCAA00" 99AABBCC DDEEFF00 Sorry if my explanation not clear enough Link to comment Share on other sites More sharing options...
mikell Posted June 20, 2023 Share Posted June 20, 2023 29 minutes ago, HezzelQuartz said: I need the search to find the first, second, fourth, fifth octet in order, whatever the third octet (XXXXXXXX) is This question implies that you already know the content of the first, second, fourth, fifth octets, and that you want to get the whole sequence of 5 octets So maybe this ? #Include <Array.au3> $s = "ABCDEFAB 11223344 55667788 66AA66BB 99AABBCC DDEEFF00 12345678" & @crlf & _ "12345678 11223344 55667788 99CCAA00 99AABBCC DDEEFF00 ABCDEFAB" $res = StringRegExp($s, '11223344 55667788 [[:xdigit:]]{8} 99AABBCC DDEEFF00', 3) _ArrayDisplay($res) Link to comment Share on other sites More sharing options...
Andreik Posted June 20, 2023 Share Posted June 20, 2023 56 minutes ago, HezzelQuartz said: @Andreik But, in this case, I don't know what is XXXXXXXX and cannot determine what is XXXXXXXX So, I need the search to find the first, second, fourth, fifth octet in order, whatever the third octet (XXXXXXXX) is not a problem For Example, the search can find these two sequence below 11223344 55667788 "66AA66BB" 99AABBCC DDEEFF00 11223344 55667788 "99CCAA00" 99AABBCC DDEEFF00 Sorry if my explanation not clear enough You don't have to know anything, in the matches array you will have all sequences indexed. Pick the 3rd sequence or whatever. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
HezzelQuartz Posted August 2, 2023 Author Share Posted August 2, 2023 @Andreik @mikell Wooow, I'm really thankful for all your help. I have one more question please. What if I need to know the sequence between two first octet and two last octet? "11223344 55667788 66AA66BB 99AABBCC DDEEFF00" "11223344 55667788 4455AACC DDEEBBDD 99AABBCC DDEEFF00" I want to know 66AA66BB in the first example and 4455AACC DDEEBBDD in the second example. Link to comment Share on other sites More sharing options...
Andreik Posted August 2, 2023 Share Posted August 2, 2023 (edited) You can write a more specialized function that will allow you to trim a certain number of octets from both sides. Here is an example: $sData = '11223344 55667788 66AA66BB 99AABBCC DDEEFF00' ConsoleWrite(TrimDW($sData, 2, 2) & @CRLF) $sData = '11223344 55667788 4455AACC DDEEBBDD 99AABBCC DDEEFF00' ConsoleWrite(TrimDW($sData, 2, 2) & @CRLF) Func TrimDW($sData, $iLeft = 0, $iRight = 0) Local $sResult Local $aMatches = StringRegExp($sData, '([0-9a-fA-F]{8})', 3) If Not IsArray($aMatches) Then Return SetError(1, 0, Null) Local $iMatches = UBound($aMatches) If $iMatches < $iLeft Then Return SetError(2, 0, Null) If $iMatches < $iRight Then Return SetError(3, 0, Null) If $iMatches < $iLeft + $iRight Then Return SetError(4, 0, Null) For $Index = $iLeft To $iMatches - $iRight - 1 $sResult &= $aMatches[$Index] & ' ' Next Return StringTrimRight($sResult, 1) EndFunc or if you always want to trim 2 groups from left and 2 from right you can use this $sData = '11223344 55667788 66AA66BB 99AABBCC DDEEFF00' $sNew = StringRegExpReplace($sData, '^(([0-9a-fA-F]{8} )){2}|(( [0-9a-fA-F]{8}){2})$', '') ConsoleWrite($sNew & @CRLF) $sData = '11223344 55667788 4455AACC DDEEBBDD 99AABBCC DDEEFF00' $sNew = StringRegExpReplace($sData, '^(([0-9a-fA-F]{8} )){2}|(( [0-9a-fA-F]{8}){2})$', '') ConsoleWrite($sNew & @CRLF) BTW an octet it's a single byte and you want to trim 8 bytes from each side in the form of 2 double word. Edited August 2, 2023 by Andreik When the words fail... music speaks. 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