Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #31  
Old February 11th, 2013, 04:51 PM
the_passenger the_passenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 44 the_passenger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 44 m 41 sec
Reputation Power: 1
Ahh, I will do some more later. It sounds like I have been using the indexOf method completely wrong.

Reply With Quote
  #32  
Old February 11th, 2013, 05:20 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
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.

Reply With Quote
  #33  
Old February 11th, 2013, 05:55 PM
the_passenger the_passenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 44 the_passenger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 44 m 41 sec
Reputation Power: 1
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.

Reply With Quote
  #34  
Old February 11th, 2013, 06:33 PM
MrFujin's Avatar
MrFujin MrFujin is offline
Lord of the Dance
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2003
Posts: 3,129 MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 22 h 57 m 20 sec
Reputation Power: 1736
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?

Reply With Quote
  #35  
Old February 11th, 2013, 06:41 PM
the_passenger the_passenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 44 the_passenger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 44 m 41 sec
Reputation Power: 1
Quote:
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

Quote:
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.

Reply With Quote
  #36  
Old February 11th, 2013, 06:41 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
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.

Reply With Quote
  #37  
Old February 11th, 2013, 07:33 PM
the_passenger the_passenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 44 the_passenger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 44 m 41 sec
Reputation Power: 1
Quote:
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.

Reply With Quote
  #38  
Old February 11th, 2013, 07:51 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
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.

Reply With Quote
  #39  
Old February 11th, 2013, 08:21 PM
the_passenger the_passenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 44 the_passenger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 44 m 41 sec
Reputation Power: 1
You've lost me, boss.

Reply With Quote
  #40  
Old February 11th, 2013, 08:37 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
What characters delimit the String: "Here" in the String: "xHerez"
What character is before "Here" and what character is after "Here"?

Reply With Quote
  #41  
Old February 11th, 2013, 09:05 PM
the_passenger the_passenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 44 the_passenger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 44 m 41 sec
Reputation Power: 1
Quote:
Originally Posted by NormR
What characters delimit the String: "Here" in the String: "xHerez"

x and z
Quote:
What character is before "Here" and what character is after "Here"?


x is before and z is after.

Reply With Quote
  #42  
Old February 11th, 2013, 09:18 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
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.

Reply With Quote
  #43  
Old February 11th, 2013, 09:39 PM
the_passenger the_passenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 44 the_passenger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 44 m 41 sec
Reputation Power: 1
Quote:
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
Quote:
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

Quote:
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
Quote:
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.

Reply With Quote
  #44  
Old February 12th, 2013, 03:17 AM
MrFujin's Avatar
MrFujin MrFujin is offline
Lord of the Dance
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Oct 2003
Posts: 3,129 MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level)MrFujin User rank is General 11st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 22 h 57 m 20 sec
Reputation Power: 1736
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?

Reply With Quote
  #45  
Old February 12th, 2013, 05:48 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
Quote:
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Filtering Strings

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap