"Case Sensitive" Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Papajo

    #1

    "Case Sensitive" Question

    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:


  • Mick White

    #2
    Re: "Case Sensitive" Question

    Papajo wrote:
    [color=blue]
    > 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
    >[/color]
    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"+ar ray[index]+"\\b","gi")
    String.replace( regex,"---")


    Mick

    Comment

    • Lee

      #3
      Re: "Case Sensitive" Question

      Papajo said:[color=blue]
      >
      >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[/color]

      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."

      Comment

      • Michael Winter

        #4
        Re: "Case Sensitive" Question

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

        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.or g/>) your mark-up.

        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • rf

          #5
          Re: &quot;Case Sensitive&quot; Question

          "Lee" <REM0VElbspamtr ap@cox.net> wrote[color=blue]
          > Papajo said:[color=green]
          > >
          > >Hi,
          > > This script is designed to remove foul language from a document,[/color][/color]
          [color=blue]
          > By the way, consider what your code does to this text:
          >
          > "Why, hello madam. I assume you have a reservation."[/color]

          Didn't do anything at all to "an Australian got kicked in the arse" :-)


          Comment

          • Dr John Stockton

            #6
            Re: &quot;Case Sensitive&quot; Question

            JRS: In article <7512-41FCFC40-20@storefull-3332.bay.webtv. net>, dated
            Sun, 30 Jan 2005 10:24:48, seen in news:comp.lang. javascript, Papajo
            <dot4444@webtv. net> posted :
            [color=blue]
            > This script is designed to remove foul language from a document,[/color]

            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.demo n.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.idiotsdelig ht.net/minitrue/> Update hope?

            Comment

            Working...