Simucal Posted April 30, 2006 Share Posted April 30, 2006 (edited) I want to use StringRegExp has a search function. Here is my current expression: (?i)\[(\s*?'&$searchstring&'.*?):\s(.*?)\s\] It is a little off. It works if I am searching for the begining of a font name, but I cant search for a word/letters in the middle of the fontname space (between '[' and ':'). I know this is possible. Here are some examples of what it is parsing: [ Verdana Italic (TrueType) : verdanai.TTF ][ Viking Medium (TrueType) : C:\WINDOWS\Fonts\_LDS_Viking.ttf ] [ Viner Hand ITC (TrueType) : VINERITC.TTF ] [ Vinque (TrueType) : C:\WINDOWS\Fonts\_LDS_vinque.ttf ] [ Vivaldi Italic (TrueType) : VIVALDII.TTF ] [ Vladimir Script (TrueType) : VLADIMIR.TTF ] [ Webdings (TrueType) : webdings.TTF ] [ Wide Eyed (TrueType) : C:\WINDOWS\Fonts\_LDS_Wide Eyed.ttf ] [ Wide Latin (TrueType) : LATINWD.TTF ] [ WingDings (TrueType) : WINGDING.TTF ] [ Wingdings 2 (TrueType) : WINGDNG2.TTF ] [ Wingdings 3 (TrueType) : WINGDNG3.TTF ] [ WST_Czec (All res) : wst_czec.FON ] [ WST_Engl (All res) : wst_engl.FON ] [ WST_Fren (All res) : wst_fren.FON ] [ WST_Germ (All res) : wst_germ.FON ] [ WST_Ital (All res) : wst_ital.FON ] [ WST_Span (All res) : wst_span.FON ] [ WST_Swed (All res) : wst_swed.FON ] [ Zekton Free (TrueType) : C:\WINDOWS\Fonts\_LDS_zekton free.ttf ] My goal, is to have it search what is in between the '[' and ':' for my $searchstring. Not just at the begining, but anywhere in that space. Then if it matches it will put the full text between the '[' and ':' in one grouping and between the ':' and the ']' in another. So if the entry was: [ Wingdings 2 (TrueType) : WINGDNG2.TTF ] It would result in: $searchresults[0] = Wingdings 2 (TrueType) $searchresults[1] = WINGDNG2.TTF I would like to be able to have my $searchstring = "ding", OR $searchstring = "wing", OR $searchstring = "dings 2", etc. I have everything worked out, EXCEPT the correct RegExpression and this one is really giving me a rough time. I dont really want do it with anything other than StringRegExp either, this is more of a lesson for me then anything. Neogia and I were going over it earlier but we didnt come up with a solution. If any stringregexp buff's out there wanna give it a try, feel free. Thanks, -Sim P.S. - Sorry my post was so scatter brained.. I hope I got my point across. P.S.S. - Here is my script incase someone wants to test out a possible expression: #include <array.au3> Dim $FontNames[1], $i = 1, $finalresults While 1 $temp = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", $i) If @error <> 0 then ExitLoop $temp2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",$temp) _ArrayInsert ( $FontNames, ($i-1), "[ "&$temp&" : "&$temp2&" ]") $i = $i + 1 Wend _ArraySort($FontNames) _arraydisplay($FontNames, "Font Names & Files"); uncomment this line if you want to see what the array looks like that holds all the font names/files $FontNamesString = _ArrayToString($FontNames,@cr) ClipPut($FontNamesString) $searchstring = InputBox("Search", "Enter the name of the font you are searching for:") If $searchstring = "" Then MsgBox(0,"Error", "You didnt enter a font name!") Exit EndIf $searchresults = StringRegExp($FontNamesString, '(?i)\[(\s*?'&$searchstring&'.*?):\s(.*?)\s\]', 3) If IsArray($searchresults) = 1 Then For $i = 1 to (UBound($searchresults)/2) $finalresults = $finalresults & "Font: "& $searchresults[(($i*2)-2)] & @CRLF&"Filename: " & $searchresults[(($i*2)-1)]&@CRLF&@CRLF Next MsgBox(0,"Found!","Search String: "&$searchstring&@CRLF&$finalresults) Else MsgBox(0,"Not Found!", "Could not find font: "&$searchstring) EndIf Exit Edited April 30, 2006 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Simucal Posted May 1, 2006 Author Share Posted May 1, 2006 (edited) Neogia saved the day, he figured it out. Apparently there is an unresolved problem with the AutoIt RegEx engine that requires you to mark '[ ]' or '( )' with a double backslash when using them in a "do everything but" group. It works great now. -Simucal Edited May 1, 2006 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Lapo Posted May 1, 2006 Share Posted May 1, 2006 great ... for a win9x : While 1 $temp = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts", $i) If @error <> 0 then ExitLoop $temp2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts",$temp) _ArrayInsert ( $FontNames, ($i-1), "[ "&$temp&" : "&$temp2&" ]") $i = $i + 1 Wend Link to comment Share on other sites More sharing options...
Simucal Posted May 1, 2006 Author Share Posted May 1, 2006 Nice catch, I'll have it check OS and check the correct registry entry accordingly. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
Lapo Posted May 1, 2006 Share Posted May 1, 2006 Nice catch, I'll have it check OS and check the correct registry entry accordingly.yes :@OSType Returns "WIN32_NT" for NT/2000/XP/2003 and returns "WIN32_WINDOWS" for 95/98/Me 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