Suja Posted March 28, 2006 Posted March 28, 2006 Hi I am trying to make a script there read from a document and censur fuck and stfu and stuff like that but how can i read the ohter lines in the document $file = FileOpen("spam.txt", 0) If $file = -1 Then MsgBox(0, "", "cant open the file") EndIf $text = StringReplace("aaa fuck stfu", FileReadLine($file, 1) &, "****") $numreplacements = @extended MsgBox(0, "New string is", $text) MsgBox(0, "The number of replacements done was", $numreplacements
Moderators SmOke_N Posted March 28, 2006 Moderators Posted March 28, 2006 (edited) I would imagine that StringRegExpReplace() would probably be much faster. Here is a wonderful starter guide if you don't know how to use StringRegExp(): http://www.autoitscript.com/forum/index.php?showtopic=23627Edit:Typo Edited March 28, 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.
Suja Posted March 28, 2006 Author Posted March 28, 2006 (edited) i get this error then i try to use the stringregexp C:\Documents and Settings\Jannik\Skrivebord\example1.au3 (1) : ==> Unknown function name.: MsgBox(0, "SRE Example 1 Result", StringRegExp("text", 'test')) MsgBox(0, "SRE Example 1 Result", ^ ERROR im just using the beta run that works Edited March 28, 2006 by Suja
Moderators SmOke_N Posted March 28, 2006 Moderators Posted March 28, 2006 (edited) i get this error then i try to use the stringregexp C:\Documents and Settings\Jannik\Skrivebord\example1.au3 (1) : ==> Unknown function name.: MsgBox(0, "SRE Example 1 Result", StringRegExp("text", 'test')) MsgBox(0, "SRE Example 1 Result", ^ ERROR im just using the beta run that worksYou have to have Beta.... Once you download beta, you'll run it from SciTe using Alt+F5. Then you can try this and see if it gives the desired result:Local $Filter[4] = ['', 'fark', 'chit', 'astp'] Local $string = 'We all like to Fark, but what is the farking point if your going to be astpholes about it all that chit I mean?' For $i = 1 To UBound($Filter) - 1 $new = StringRegExpReplace($string, '(?i:' & $Filter[$i] & ')', '****') $string = $new Next MsgBox(0, '', $string) This actually works:Local $Filter[4] = ['', 'fark', 'chit', 'astp'] Local $String = FileRead(@DesktopDir & '\TXT_Files\testing.txt') For $i = 1 To UBound($Filter) - 1 $new = StringRegExpReplace($String, '(?i:' & $Filter[$i] & ')', '****') $String = $new Next FileWrite(@DesktopDir & '\TestComplete.txt', $String) Edited March 28, 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.
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