How To Filter A String

Posted by Siert on July 15, 2008, 9:26 p.m.

//starts arguments

var fstring, caps, offensive, filtered;

fstring=argument0

//creates list of offensive words

offensive = ds_list_create()

This is where the offensive words are added.

Example:

ds_list_add(offensive,"wth")

Add as many as you want.

To see my list and save some time, click here.

Save other people some time and your words there!

//save capital positions

caps=ds_list_create()

global.caps = caps

for(p=1; p<=string_length(k); p+=1){

if string_char_at(fstring,p)=string_letters(string_upper(string_char_at(fstring,p)))

ds_list_add(caps,p)}

//save symbol positions

symbpos=ds_list_create()

global.symbpos = symbpos

symb=ds_list_create()

global.symb = symb

for(p=1; p<=string_length(fstring); p+=1){

if string_char_at(fstring,p)!=string_letters(string_char_at(fstring,p)){

ds_list_add(symb,string_char_at(fstring,p))

ds_list_add(symbpos,p)}}

//replaces symbols with possible letter counterparts

fstring=string_replace_all(fstring,'1','i')

fstring=string_replace_all(fstring,'!','i')

fstring=string_replace_all(fstring,'3','e')

fstring=string_replace_all(fstring,'5','s')

fstring=string_replace_all(fstring,'8','b')

fstring=string_replace_all(fstring,'0','o')

fstring=string_replace_all(fstring,'()','o')

fstring=string_replace_all(fstring,'@','a')

fstring=string_replace_all(fstring,'$','s')

fstring=string_replace_all(fstring,'z','s')

//make string lowercase

fstring = string_lower(fstring)

//stars out bad words

var star;

star=''

for(ds=0; ds<ds_list_size(offensive); ds+=1){

star=''

//generates string of correct number of stars

for(a=0; a<string_length(ds_list_find_value(offensive,ds)); a+=1)

star+='*'

fstring = string_replace_all(fstring,ds_list_find_value(offensive,ds),star)}

//puts stars the original string with numbers and symbols

for(l=1; l<=string_length(fstring)+1; l+=1){

if string_char_at(fstring,l)='*'{

filtered = string_delete(filtered,l,1)

filtered = string_insert('*',filtered,l)}}

//returns a filtered string

return filtered

I'm pretty sure that counts as content.

Go filter your games!

Hey! Add words to the list here!

EDIT: God is included because I don't want people going "God Damnit" every where. Which IS offensive to me because I AM a Christian!

STOP THE FLAMES!

And Arc, WHY does my filtering fail?

Comments

SteveKB 16 years, 5 months ago

i think that you should make it check any part of a string, i entered an example …. [wii]

Chaz 16 years, 5 months ago

Wow! Very good idea! lol

Btw, in your list thing, why is wtf in there? I thought that was the proper way to say it with spelling it out lol!

Cesque 16 years, 5 months ago

Quote:
OK that is offensive to a person that is Christian faith

You forgot the Muslims, among thousands of other religions… if you're adding "Christ", you may as well add "Muhammad", "Allah", and since you're at it, "Moses" and "Adam". Nevermind anyone named Adam, since you already don't mind Spanish guys named Jesus…

Quote:
Oral? Offensive?

Two years of linguistic studies make you couple "oral" with "nasal" instantly. Picturing nasal sex is a hilarious experience.

Oh, and by the way, nice code :) Playing with strings is fun, someday I gotta do it for more creative purposes (eg. phonotactics-contrained syllable-based name generation for my RPG ;))

eagly 16 years, 5 months ago

Quote:
Picturing nasal sex is a hilarious experience.
I think I would describe it more as painful. But hey, whatever floats your boat, mate. ;) :p

DT-170x 16 years, 5 months ago

OK that is offensive to a person that is Christian faith

ds_list_add(offensive,"jesus")

ds_list_add(offensive,"christ")

ds_list_add(offensive,"god")

Why you bag the christion Faith why you do this

ds_list_add(offensive,"Siert")

IF you do this game add other faith in there too. I wont play it anywhey you might put this in your game

ds_list_add(offensive,"DT-170x")

And tell me why these words are offensive.

Arcalyth 16 years, 5 months ago

Like I said before, DT-170x, who is he going to get in trouble with?

Also, his filtering fails anyway, Regex is more effective.

Cesar 16 years, 5 months ago

It's SO very offensive to use those words as an example that you can edit for your own game.

It's also so very offensive that the church prohibits gay marriage to those who are gay.

It's also so very offensive that the church condemns movies that are written by an atheist showing the horrid past of the church.

Now shut the fuck up 170, it's getting me pissed off that you have horrible grammar and complain about everything.

DT-170x 16 years, 5 months ago

What is Rejax

And RawSpoon maybe I ani't the goodest person in English SO What.

Cesque 16 years, 5 months ago

Quote:
And RawSpoon maybe I ani't the goodest person in English SO What.

This isn't the problem, the problem is you're living in a bloody English-speaking country.

DT-170x 16 years, 5 months ago

That is before I use Firefox and I did not even saw that typo.