Sign in to follow this  
Followers 0
Suja

Censur^^

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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=23627

Edit:

Typo

Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Suja

Share this post


Link to post
Share on other sites

#4 ·  Posted (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

You 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 by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0