Web Analytics Made Easy -
StatCounter How do i test missing string w/a piece of code - CodingForum

Announcement

Collapse
No announcement yet.

How do i test missing string w/a piece of code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do i test missing string w/a piece of code

    How do I test if a word is missing from a string. For example, the following contains a missing word:

    var test = "this is a "

    Please send me some ideas.

  • #2
    You could use the charAt() function.
    I try to convince 'em that I am computer geek, but I just can't do it. Why? Oh why?

    Comment


    • #3
      How can I do this non-programmatically.

      Comment


      • #4
        Huh? What do you mean by non-programmatically? What is your criteria for determining there is a missing word? If you can answer these questions maybe we can help out more.

        Comment


        • #5
          well the basic way is

          mainString.indexOf("your String")

          that is:

          var foo1="hallo world how are you?"

          var foo2="are you?"

          foo1.indexOf(foo2)

          produces -1 (LESS 1 if the string foo2 is not present INSIDE foo1) or a positive number if it is present.

          I don't know what you mean by non programmatically. Arguably, you're wondering if there is a way to do it by html, but no: only a scripting language can let you do these things: html is static (in the sense it is not a scripting or programming language!)

          ciao

          PS John, I apologize if I meddle with this but I was struck by the quotation in your signature for it is clearly Descartes and a beautiful sentence actually, but maybe I don't know enouhg english so maybe "codito" has some meaning in english and was meant as an intentional change, but if wasn't so and obviously if I'm not kistaken the original latin sentence is "cogito ergo sum", g instead of d: a fascinating sentence by Descartes, anyway! Good choice!
          Last edited by TrueLies; Jun 19, 2002, 05:32 PM.
          Alberto http://www.unitedscripters.com/

          Comment


          • #6
            No worries I love it when other members jump right in!

            Codito is meant to be a play on words. While Descartes is famous for "Cognito Ergo Sum", I think therefore I am. I take it to a differnt plain with "Codito Ergo Sum" a bit of Psuedo Latin for I code therfore I am. I actually saw this phrase on the t-shirt of one of my developers and instantly fell in love with it.

            Comment


            • #7
              Thanks, TrueLies. Yes, I meant HTML way by saying non-programmatically. I think you're just being humble when you say you don't know much English.

              Comment


              • #8
                Originally posted by JohnKrutsch
                I take it to a differnt plain with "Codito Ergo Sum" a bit of Psuedo Latin for I code therfore I am.
                /me just a whispers® to john....
                :O))) just a ta® for the explanation.../me just a lways® wondered what thattt meant...hehehe...
                /me does notepad™ nottt latin...rotflmao!!! 'cept sometimes??? /mes code look like just a greek®...hehehe...
                The New JustaBuster Version 2.0 OR JustaBusta Lite V2.0
                ...just a special® thanx kinda hugs to jkd n' nex ...:O)))

                CommemorateWTC.com --Please lend your support

                Comment

                Working...
                X