CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2011
    Posts
    19

    Exclamation Finding similar strings!

    I have got a set of strings having names of celebrities like -

    1) Chuck Norris
    2) David guetta
    3) Adam Lambert
    4) Sylvester S
    5) Ricky Martin
    6) Morgan Freeman
    7) Ronald Atkinson
    8) Britney Spears
    9) Chuck
    10) John Cena
    11) John Trovolta
    12) Zack Effron
    13) Tom Cruise
    14) Amy McDonald
    15) C Ronaldo
    16) Morgan Freeman.....

    Now I need to find out similar names like 1,9 are similar, how do I make the app to find it?
    If someone could give the snippet, it would be great!
    Last edited by BlitzBerg; December 30th, 2011 at 04:46 AM.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Finding similar strings!

    Not enough info to give an answer.

    What is the it you are looking to find?
    How are these strings stored?

    If you want a decent answer to your question you must first take the time to type out a clear description of your question.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Dec 2011
    Posts
    19

    Exclamation Finding similar strings!

    I have got strings having names like
    1) Chuck Norris
    2) C. Norris
    3)Chuck
    3) Chuckie.....

    now since all of them are similar, how do I make the app to find it?
    If someone could give the snippet, it would be great!

  4. #4
    Join Date
    Dec 2011
    Posts
    19

    Re: Finding similar strings!

    Okay, I updated it. I hope I'm clear now.

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Finding similar strings!

    Double post.

    Do not create more than one thread for the same question.

    See other thread
    Last edited by DataMiser; December 30th, 2011 at 04:34 PM.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Finding similar strings!

    You did not tell us how these strings are stored. Are we talking a database? a List? an Array? Individual Variables, a text file or what.

    Your odds of getting the correct answer are very low if you do not provide enough info to allow us to have an idea of what you are attempting.

    Have you written some code for this already? Show us the code, tell us what it is or is not doing then maybe someone can help.
    Last edited by DataMiser; December 30th, 2011 at 04:33 PM.
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Dec 2011
    Posts
    19

    Re: Finding similar strings!

    I haven't written anything as yet as I'm not clear with the idea!, but let us assume, these are stored in an array.

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Finding similar strings!

    Well if you were using a database you could use a like clause as part of your select statement to handle some variants but even then there is no gaurantee that the results would be what you seek.
    In the case of an array you would need to loop through the array checking for variations, either by doing multiple tests on each element or by running more than one loop with a different search parameter. Perhaps create a function that checks the array for an instance. To find all the instances in your first post without getting anything that may not be a match may prove to be difficult especially if you have lots of enteries with similar variations of other names.

    Woudl be much simplier to standardize the data.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured