#31
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    44
    Rep Power
    2
    Ahh, I will do some more later. It sounds like I have been using the indexOf method completely wrong.
  2. #32
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    The indexOf() method would find the location of "cat". Then look at the character before it and the character after it. Their identity would say if "cat" was a word or was a subpart of another larger word.
  4. #33
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    44
    Rep Power
    2
    I still don't get it. So I get various numbers that relate to index positions:

    cat is happy

    where icat

    hi cat whats up

    turn cat


    ....0, 7, 3, 5, etc...I don't understand what that does for me. I can get the length but...I don't see how that helps me any either. Yes, it should be three, but it will be that way with cat or catacomb.
  6. #34
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,535
    Rep Power
    1906
    If you look at second example with the icat.
    You got the index of 7, what result will you get if you look at the character in front of c (index-1)? what does this tell related/compared to what is a valid delimiter?
  8. #35
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    44
    Rep Power
    2
    Originally Posted by MrFujin
    You got the index of 7, what result will you get if you look at the character in front of c (index-1)?
    charAt(6) = i

    what does this tell related/compared to what is a valid delimiter?
    It tells me that every possible character is a possibility before and after the word cat. Given words like catacomb, I don't know how to tell with them...This is probably where I am going wrong.
  10. #36
  11. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    Do you know what the term "delimiter" means?
    Most words we type are delimited by spaces.
    Other delimiters are the beginning of a sentence.
    Other delimiters for words are comma and period.
    If a String is delimited by any of these characters then it is a word. If it has other delimiters then it is NOT a word.
    Your search is for words like cat not category. In category, cat has a following delimiter of e which makes the cat in category not a word.
    Last edited by NormR; February 11th, 2013 at 06:43 PM.
  12. #37
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    44
    Rep Power
    2
    Originally Posted by NormR
    Do you know what the term "delimiter" means?
    Most words we type are delimited by spaces.
    Other delimiters are the beginning of a sentence.
    Other delimiters for words are comma and period.
    If a String is delimited by any of these characters then it is a word. If it has other delimiters then it is NOT a word.
    Your search is for words like cat not category. In category, cat has a following delimiter of e which makes the cat in category not a word.
    Hardly, we never went over them in class, although there was a brief mention of them in Chapter 2. I messed around with them, but they didn't make a lot of sense to me. Should I be using a delimiter in my program?

    If I use cat as delimiter, it will cutoff the rest of the input from wherever cat ends up getting typed.
  14. #38
  15. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    The delimiters I have been talking about are single characters that mark the ends of a String to identify words. The String "cat" would not be called a delimiter.
    In the String: "xHerex" the character x is the delimiter for the word: Here

    The delimiter I am talking has nothing to do with any args to methods in java. It is being used as a common English word.
  16. #39
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    44
    Rep Power
    2
    You've lost me, boss.
  18. #40
  19. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    What characters delimit the String: "Here" in the String: "xHerez"
    What character is before "Here" and what character is after "Here"?
  20. #41
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    44
    Rep Power
    2
    Originally Posted by NormR
    What characters delimit the String: "Here" in the String: "xHerez"
    x and z
    What character is before "Here" and what character is after "Here"?
    x is before and z is after.
  22. #42
  23. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    Given the String: "xherez"
    Now if we change the x to a t and the z to a space we get: "there "
    Does that String have the word here in it?

    Next change the x to a space and the z to a space we get: " here "
    Does that String have the word here in it?

    Next change the x to a space and the z to a period we get: " here."
    Does that String have the word here in it?

    Notice how what values the delimiting characters have determines if there is a word or not. spaces or a period make a word, others do not.
  24. #43
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    44
    Rep Power
    2
    Originally Posted by NormR
    Given the String: "xherez"
    Now if we change the x to a t and the z to a space we get: "there "
    Does that String have the word here in it?
    Yes
    Next change the x to a space and the z to a space we get: " here "
    Does that String have the word here in it?
    Yes

    Next change the x to a space and the z to a period we get: " here."
    Does that String have the word here in it?
    Yes
    Notice how what values the delimiting characters have determines if there is a word or not. spaces or a period make a word, others do not.
    I follow this, at least I think I do, thank you...but I still have no idea how this relates to cat and category.
  26. #44
  27. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,535
    Rep Power
    1906
    IF you look at these two sentence:
    - This cat is mine
    - This catacomb is mine

    Why is the cat in second sentence not a profane word? you say it is part of a word?
    How can you see that it is part of a word?
    Generally speaking, how do you separate one word from each other?
  28. #45
  29. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    how this relates to cat and category.
    Its a way to find the difference. You want to detect the word cat and not the word category.

IMN logo majestic logo threadwatch logo seochat tools logo