String issue..
-
Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.
Program your life ^^
-
Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.
Program your life ^^
Lots of them but this looks like homework. I imagine the Vector class is somewhere in your near future and use of the contains method.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed. -
Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.
Program your life ^^
Hi, this would be my attempt: - strip all redundant characters from each string, probably every non-letter; - optionally: normalize the casing, say convert all strings to lower-case; - collect the strings in a List<string>, however before adding them, check whether the new string is already present; if so you found a duplicate. (you can improve on this by using a Dictionary which holds the string as a key, and the occurence count as an int value). BTW: why ask for an algorithm in a language oriented forum that does not match your language? we do have a "Math and algorithms" forum. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:38 PM
-
Hi, this would be my attempt: - strip all redundant characters from each string, probably every non-letter; - optionally: normalize the casing, say convert all strings to lower-case; - collect the strings in a List<string>, however before adding them, check whether the new string is already present; if so you found a duplicate. (you can improve on this by using a Dictionary which holds the string as a key, and the occurence count as an int value). BTW: why ask for an algorithm in a language oriented forum that does not match your language? we do have a "Math and algorithms" forum. :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:38 PM
-
Luc Pattyn wrote:
BTW: why ask for an algorithm in a language oriented forum that does not match your language? we do have a "Math and algorithms" forum.
Is not the forum called "Algorithms", I don't see "Math" there? :)
Ravadre wrote:
Is not the forum called "Algorithms",
it has been called "Algorithms and Math", as well as "Math and algorithms" before. However you are right, this week it is called "Algorithms". :laugh:
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:38 PM
-
Hi everyone! I'm working on a project and i need to do what follows: i have an array of strings,example: house3 house2 green23 green.5 H6 H01 G19 G78 ..and so on. I have to extract only the recurrent strings: house,green,H,G. Any idea about it? (the language is java but doesn't matter, i just need the idea!) Thanks in advance, Enrico.
Program your life ^^
try using regular expressions....using remove method.. removing pattern[0-9]
the quieter u become more u hear
-
try using regular expressions....using remove method.. removing pattern[0-9]
the quieter u become more u hear