By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,938 Members | 1,580 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,938 IT Pros & Developers. It's quick & easy.

"Case Sensitive" Question

P: n/a
Hi,
This script is designed to remove foul language from a document, the
question is that it will only remove what is put into the array, these
words are in lowercase, now how can I have the script parse the document
in lowercase?
If foul words start with a cap or their in uppercase the script won't
remove them.
I tried putting .toLowerCase(); into different parts of the script and
it powered me off a few times. Any help is appreciated. Thanks Joe

PS: this is a basic version of the script:
http://web2jo.com/TBed/LangFilter.html

Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Papajo wrote:
Hi,
This script is designed to remove foul language from a document, the
question is that it will only remove what is put into the array, these
words are in lowercase, now how can I have the script parse the document
in lowercase?
If foul words start with a cap or their in uppercase the script won't
remove them.
I tried putting .toLowerCase(); into different parts of the script and
it powered me off a few times. Any help is appreciated. Thanks Joe

PS: this is a basic version of the script:
http://web2jo.com/TBed/LangFilter.html

I think your whole approach is somewhat flawed, I would use regular
expressions to parse out objectionable words. As it is now, "assume"
becomes "---ume".

String.replace(/\bass\b/gi,"---").replace(/\bdamn?\b,"---") etc.

or you could loop through the banned words:
regex=new RegExp("\\b"+array[index]+"\\b","gi")
String.replace(regex,"---")
Mick
Jul 23 '05 #2

P: n/a
Lee
Papajo said:

Hi,
This script is designed to remove foul language from a document, the
question is that it will only remove what is put into the array, these
words are in lowercase, now how can I have the script parse the document
in lowercase?
If foul words start with a cap or their in uppercase the script won't
remove them.
I tried putting .toLowerCase(); into different parts of the script and
it powered me off a few times. Any help is appreciated. Thanks Joe

PS: this is a basic version of the script:
http://web2jo.com/TBed/LangFilter.html


What in the world does "it powered me off a few times" mean?

Your code is unreadable. You use too many single character
variable names and the formatting is useless. I do see that
you use eval() where it is not required, and I don't see any
indication that you're using regular expression matching,
which is the simple solution to your problem.

By the way, consider what your code does to this text:

"Why, hello madam. I assume you have a reservation."

Jul 23 '05 #3

P: n/a
On Sun, 30 Jan 2005 10:24:48 -0500, Papajo <do*****@webtv.net> wrote:
This script is designed to remove foul language from a document [...]


You should seriously consider what is "foul language". I would be hard
pressed to find anyone I know who thinks that the words filtered in your
example are offensive, irrespective of their usage (and by the way, dam
should be damn).

On a different note, HTML 3.2 is out-dated. Learn modern HTML and CSS, and
validate (<URL:http://validator.w3.org/>) your mark-up.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

P: n/a
rf
"Lee" <RE**************@cox.net> wrote
Papajo said:

Hi,
This script is designed to remove foul language from a document,
By the way, consider what your code does to this text:

"Why, hello madam. I assume you have a reservation."


Didn't do anything at all to "an Australian got kicked in the arse" :-)
Jul 23 '05 #5

P: n/a
JRS: In article <75**************@storefull-3332.bay.webtv.net>, dated
Sun, 30 Jan 2005 10:24:48, seen in news:comp.lang.javascript, Papajo
<do*****@webtv.net> posted :
This script is designed to remove foul language from a document,


Do you really wish to assert that you know all possible foul words? In
all languages? What is your opinion of fewmet, for example; or frazil?

Has it occurred to you that it is possible to generate foul expressions
from perfectly innocuous words? Or that some words are perfectly
acceptable in some contexts but not in others?

There's a word in the language defined by CSS which in combination with
a word used in a perfectly respectable manner in golf describes a type
of astronomical object. But I've heard that if those innocuous words
are translated literally into Russian the result is indescribably rude.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> Update hope?
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.