We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi !
It's quiet difficult to explain but what i want to do is to compare a string with a random text (Strings text) inside and a list of surnames (Strings surnames). When that's done, i'm trying to print all the match with the surname with an other array contains some surnames and lastnames (Strings fullnames).
Might be better with an example :
Strings text = "The surname is William";
Strings [] surnames = {"John","David","William","James"};
Strings [] fullnames = {"John number1","David number1","David number1","William number1","William number2","William number3","James number1"};
and what i want i want to print is =
William number1
William number2
William number3
Don't know if you understand but if you have a piece of answer im glad to hear it !!!
Thanks a lot !
RM
PS : sorry for my english ...
Answers
Hi, have a look at this thread, it's similar to your question. Maybe u can try something and get back for more help if needed. : )
http://forum.processing.org/two/discussion/1106/calculate-specific-word-frequency-in-text#Item_3
Actually there are two posts, and this is the first one, go here first : )
http://forum.processing.org/two/discussion/1236/how-to-use-arrays-to-reduce-redundancy
Would this be what your looking for?
-- MenteCode
Just in case you're wondering, you don't really need a separate array of surnames, along with an array of full names for it to search for a surname.
Thanks for both reply !
@MenteCode the indexOf method works perfectly but i wonder if its possible to choses a result in the fullnames array, like only print the second result ?
Unless this is really what you're looking for, then you would have to be a bit more specific.
But choosing a second (or any other number in order) is a very easy implementation:
-- MenteCode