Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. String issue..

String issue..

Scheduled Pinned Locked Moved C#
javadata-structureshelptutorialquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    ventomito
    wrote on last edited by
    #1

    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 ^^

    E L L 3 Replies Last reply
    0
    • V ventomito

      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 ^^

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • V ventomito

        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 ^^

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        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

        R 1 Reply Last reply
        0
        • L Luc Pattyn

          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

          R Offline
          R Offline
          Ravadre
          wrote on last edited by
          #4

          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? :)

          L 1 Reply Last reply
          0
          • R Ravadre

            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? :)

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • V ventomito

              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 ^^

              L Offline
              L Offline
              lawrenceinba
              wrote on last edited by
              #6

              try using regular expressions....using remove method.. removing pattern[0-9]

              the quieter u become more u hear

              V 1 Reply Last reply
              0
              • L lawrenceinba

                try using regular expressions....using remove method.. removing pattern[0-9]

                the quieter u become more u hear

                V Offline
                V Offline
                ventomito
                wrote on last edited by
                #7

                great idea lawrenceinba! but what do you mean with "removing the pattern"? i'm not sure to understand this way..

                Program your life ^^

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups