Noobster24 Posted June 16, 2006 Share Posted June 16, 2006 Hi,i want to check if this sentence is in a txt-file.Sentence:<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>I exspected this code to work, but it doesn't :S$file = FileOpen('C:\Documents and Settings\Beheerder\Bureaublad\Andreas\Custom \~ OSS ~\office 2003.txt',0)$test = StringRegExp ($file, '(.*)<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>(.*)',0)If $test = 1 Then MsgBox(0,"ja","ja")Else MsgBox(0,"Nee","nee")EndIfWhat's wrong with my pattern?greetings,Andreas Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc. Link to comment Share on other sites More sharing options...
w0uter Posted June 16, 2006 Share Posted June 16, 2006 (edited) .* means IIRC one or more . try it without those (.*)'s Edited June 16, 2006 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 16, 2006 Moderators Share Posted June 16, 2006 Hi,i want to check if this sentence is in a txt-file.Sentence:I exspected this code to work, but it doesn't :SWhat's wrong with my pattern?greetings,Andreasdo you just want: Result more than 50 records. Please, specify parameters of search. or all of it: <CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Noobster24 Posted June 16, 2006 Author Share Posted June 16, 2006 do you just want: Result more than 50 records. Please, specify parameters of search. or all of it: <CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>?The whole sentence, so:<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>The source of a website is written into a txt-file, i want to check if this sentence is in the txt-file... Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc. Link to comment Share on other sites More sharing options...
Noobster24 Posted June 16, 2006 Author Share Posted June 16, 2006 (edited) .* means IIRC one or more .try it without those (.*)'sOkay, i'll try...edit: Nope, doesn't work.. Edited June 16, 2006 by Noobster24 Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 16, 2006 Moderators Share Posted June 16, 2006 (edited) Okay, i'll try... edit: Nope, doesn't work..Here try this:$file = @DesktopDir & '\sre_test.txt' $FindThis = '<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>' If _SRE_Find($file, $FindThis) Then MsgBox(0, 'Info:', 'Found') EndIf Func _SRE_Find($s_FilePath, $s_Find) $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $vFound = StringRegExp($h_FRead, '(?:' & $s_Find & ')') If $vFound Then Return $vFound Return 0 EndFunc Edit: Obviously you want to change the $File (location/name) Edited June 16, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Noobster24 Posted June 16, 2006 Author Share Posted June 16, 2006 (edited) Here try this:$file = @DesktopDir & '\sre_test.txt' $FindThis = '<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>' If _SRE_Find($file, $FindThis) Then MsgBox(0, 'Info:', 'Found') EndIf Func _SRE_Find($s_FilePath, $s_Find) $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $a_Array = StringRegExp($h_FRead, '(?:' & $s_Find & ')') If $a_Array Then Return $a_Array Return 0 EndFunc I'll test it right now, i just want a 1 (true) returns if the sentence is found in the file or a 0 (false) if the sentence isn't found, not the place of the sentence. i'll keep you informed... Edit: It works, thank you! Edited June 16, 2006 by Noobster24 Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc. Link to comment Share on other sites More sharing options...
Noobster24 Posted June 16, 2006 Author Share Posted June 16, 2006 Here try this:$file = @DesktopDir & '\sre_test.txt' $FindThis = '<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>' If _SRE_Find($file, $FindThis) Then MsgBox(0, 'Info:', 'Found') EndIf Func _SRE_Find($s_FilePath, $s_Find) $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath)) $vFound = StringRegExp($h_FRead, '(?:' & $s_Find & ')') If $vFound Then Return $vFound Return 0 EndFunc Edit: Obviously you want to change the $File (location/name) Yeah, i know i must change the $File Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc. 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