Digisoul Posted October 1, 2008 Share Posted October 1, 2008 Hello ,Well guys i want to know any other Method to match the multiple strings in any target String.e.g :;I have 3 Stings in array Dim $ar[6]=["A","B","C","the","fox","dog"] ;The target string $String = "A quiCk Brown fox jumps over the lazy dog" ; Normal Method For $i = 0 to 5 if StringinStr($String,$ar[$i],2) then ConsoleWrite($ar[$i]&" > Matched In Target String"&@CRLF) endif NextSo Is there any other method to match multiple strings in any target string. i mean to say another method to do my required task ,without Loop.Actually its take much time if the Array contain many strings.Thanks in Advance. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Digisoul Posted October 1, 2008 Author Share Posted October 1, 2008 #include <array.au3> $pattern="A|B|C|the|fox|dog" $String = "A quiCk Brown fox jumps over the lazy dog" $a=StringRegExp($String,$pattern,3) _ArrayDisplay($a) Thanks Hubertus72, Its Really Cool, Bundle of Thanks. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Digisoul Posted October 1, 2008 Author Share Posted October 1, 2008 #include <array.au3> $pattern="A|B|C|the|fox|dog" $String = "A quiCk Brown fox jumps over the lazy dog" $a=StringRegExp($String,$pattern,3) _ArrayDisplay($a) LittLE Porblem, how can i match special chr ? e.g if i open any exe file in normal mode = 0 and i have YuEäEüÿEøöCtvVà÷ÿÿPÿuÿ×à÷ÿÿP| to match then what will i do ? 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
rasim Posted October 2, 2008 Share Posted October 2, 2008 LittLE Porblem, how can i match special chr ? e.g if i open any exe file in normal mode = 0and i have Yu‹Eä‰EüÿEøöCtvV…à÷ÿÿPÿuÿ×…à÷ÿÿP| to match then what will i do ?1. You can't open a binary file in the text read mode.2. StringRegExp does not work with unicode chars. Link to comment Share on other sites More sharing options...
Digisoul Posted October 4, 2008 Author Share Posted October 4, 2008 You can use the hex syntax of stringregexp(): \x## or using the binary fileread(). Here an example: #include <array.au3> $pattern="5F65786974|00052B" ;search for "_exit" or "0x00052B" $h=FileOpen(@WindowsDir&"\system32\ping.exe",16) $String = FileRead($h) FileClose($h) $a=StringRegExp($String,$pattern,3) _ArrayDisplay($a)Thanks Hubertus72 Your Solution is Really cool. Thank you all guys. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
trancexx Posted October 5, 2008 Share Posted October 5, 2008 But that is wrong. "5F65786974" may be "0x5F65786974" but may very well be a part of "0x65F657869742" and that is completely different. That is searching string inside binary data and that's not right. Special charaters can be included. Example: #include <array.au3> $pattern = Chr(65) & "|" & Chr(66) & "|" & Chr(67) & "|the|fox|dog" $String = "A quiCk Brown fox jumps over the lazy dog" $a=StringRegExp($String,$pattern,3) _ArrayDisplay($a) ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Digisoul Posted October 5, 2008 Author Share Posted October 5, 2008 (edited) But that is wrong. "5F65786974" may be "0x5F65786974" but may very well be a part of "0x65F657869742" and that is completely different. That is searching string inside binary data and that's not right. Special charaters can be included. Example: #include <array.au3> $pattern = Chr(65) & "|" & Chr(66) & "|" & Chr(67) & "|the|fox|dog" $String = "A quiCk Brown fox jumps over the lazy dog" $a=StringRegExp($String,$pattern,3) _ArrayDisplay($a) Your Rite,but in some cases(coz 0x5F65786974 is only used when you want to scan a file from its first bytes.), but my requirement is to scan a file from the bytes of EOF. So i just feed the data (pattern); from the EOF of any file. there is a simple but amaze thing that every file's bytes in EOF will diffrent(i got this experience after using a lot of Heckman HEX editor). so Hubertus72's method is exact what i want. anyways thanks. Edited October 5, 2008 by Digisoul 73 108 111 118 101 65 117 116 111 105 116 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