Jump to content

Censur^^


Suja
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

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

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
Link to comment
Share on other sites

  • Moderators

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...