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. Algorithms
  4. String matching algorithm

String matching algorithm

Scheduled Pinned Locked Moved Algorithms
algorithmsregexquestion
7 Posts 6 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
    vSoares
    wrote on last edited by
    #1

    Hi. I have a text file full of words (lets say one word per line). I want to find all words starting with a given pattern. What's the best algorithm to do this? Thanks, vSoares

    Y P F 3 Replies Last reply
    0
    • V vSoares

      Hi. I have a text file full of words (lets say one word per line). I want to find all words starting with a given pattern. What's the best algorithm to do this? Thanks, vSoares

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      vSoares wrote:

      What's the best algorithm to do this?

      well, what is your definition of best? best matches? best execution time? best ...? there are plenlenty of algorithms out them, did you try exact string match[^] or this[^]

      Yusuf May I help you?

      V 1 Reply Last reply
      0
      • Y Yusuf

        vSoares wrote:

        What's the best algorithm to do this?

        well, what is your definition of best? best matches? best execution time? best ...? there are plenlenty of algorithms out them, did you try exact string match[^] or this[^]

        Yusuf May I help you?

        V Offline
        V Offline
        vSoares
        wrote on last edited by
        #3

        Yes, I tried but i was expecting someone who had some experience with this kind of algorithms to point me in the right direction. I agree, "best" is very broad. I need a fast search algorithm. I can optimize the source if needed. It's not an exact string match. It's all strings beggining with a given pattern, something like google suggestions. vSoares

        L R 2 Replies Last reply
        0
        • V vSoares

          Yes, I tried but i was expecting someone who had some experience with this kind of algorithms to point me in the right direction. I agree, "best" is very broad. I need a fast search algorithm. I can optimize the source if needed. It's not an exact string match. It's all strings beggining with a given pattern, something like google suggestions. vSoares

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Tries and related data structures come to mind, as well as the bitap algorithm Just general suggestions..

          1 Reply Last reply
          0
          • V vSoares

            Yes, I tried but i was expecting someone who had some experience with this kind of algorithms to point me in the right direction. I agree, "best" is very broad. I need a fast search algorithm. I can optimize the source if needed. It's not an exact string match. It's all strings beggining with a given pattern, something like google suggestions. vSoares

            R Offline
            R Offline
            riced
            wrote on last edited by
            #5

            vSoares wrote:

            I need a fast search algorithm. I can optimize the source if needed.

            Sort the file then use a binary search? :)

            Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

            1 Reply Last reply
            0
            • V vSoares

              Hi. I have a text file full of words (lets say one word per line). I want to find all words starting with a given pattern. What's the best algorithm to do this? Thanks, vSoares

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Load them into a database and use SQL. :-D

              1 Reply Last reply
              0
              • V vSoares

                Hi. I have a text file full of words (lets say one word per line). I want to find all words starting with a given pattern. What's the best algorithm to do this? Thanks, vSoares

                F Offline
                F Offline
                Fatbuddha 1
                wrote on last edited by
                #7

                I think I would give it a try with regex. If you really want to program something nice, then maybe suffix trees are good. Cheers

                You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)

                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