Results 1 to 12 of 12
  1. #1
    theyoung is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Question Please Help me regarding String pattern matching

    I am having an array of String as {"jacobs", "james","thames", "thomas", "diomas"}

    need to find

    1) Compare all the strings and display the two strings which are having most matched characters

    Example: jacobs and james have j,a,s in common
    james and thames have a,m,e,s in common

    like dat we have to consider all test cases and have to disply the output if the maximum characters in common is for james and thames we have to display james and thames

    2)Print two strings from array if they are having same characters in the same index

    Example : thomas and diomas have same characters at same index...that is mas

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Please Help me regarding String pattern matching

    What is your question?
    What have you done?

  3. #3
    theyoung is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: Please Help me regarding String pattern matching

    I need to find strings having the most number of characters in common from an array of strings as I mentioned in example.....
    Last edited by theyoung; 11-07-2011 at 11:24 PM.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Please Help me regarding String pattern matching

    You have simply restated your requirement. You still have not asked a question. You still have not attempted to write any code.

    No help for you!

  5. #5
    theyoung is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: Please Help me regarding String pattern matching

    not lyk dat I wrote and found common characters in two strings...but I need help regarding its extension to fulfill given requirement

    String wordA = "thomas";

    String wordB = "dhomas";

    String common = "";


    for(int i=0;i<wordA.length();i++){

    for(int j=0;j<wordB.length();j++){

    if(wordA.charAt(i)==wordB.charAt(j)){

    common += wordA.charAt(i)+" ";

    break;

    }
    }

    }
    System.out.println("common is: "+common);

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Please Help me regarding String pattern matching

    :headdesk:

    Still no question! If you do not ask a specific question I do not know what specific answer to provide.

  7. #7
    theyoung is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: Please Help me regarding String pattern matching

    :( I have stated the requirement na ....I need to extend my code to array of string ...and i need to display the two strings from that array of string which are having most number of characters in common by all comparisons

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Please Help me regarding String pattern matching

    I don't care what you need. What I need is for you to ask a question. What about your requirements do you not understand? Does your code compile? If you get error messages then post them here. If your code runs and gives incorrect output then post what you get and what you should get. If there is a specific problem such as how to compare a certain char from one string to a certain char in a different string then ASK THAT QUESTION. Don't just keep repeating "I want....." I want a lot of money so I can retire. Can you help with that? Your posts so far are like "Here's my code, fix it for me" and I'm not doing that.

  9. #9
    theyoung is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: Please Help me regarding String pattern matching

    lol Junky ....give me some idea how to implement....how can I compare the strings and how can I find common letters in those strings.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Please Help me regarding String pattern matching

    How would you solve something like this on paper? Try to think through this logically as this isn't really a Java issue at all, but an algorithm issue. So think through what steps are required to logically solve this, and then we can worry about what code is needed.

  11. #11
    theyoung is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: Please Help me regarding String pattern matching

    :) fub I am working on dat :)

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Please Help me regarding String pattern matching

    Quote Originally Posted by theyoung View Post
    :) fub I am working on dat :)
    Good, please feel free to post the fruits of your labors when they've ripened.

Similar Threads

  1. A Question Regarding Pattern Matching
    By hadi in forum Advanced Java
    Replies: 4
    Last Post: 01-21-2011, 04:38 PM
  2. pattern matching with two arrays
    By jessie in forum New To Java
    Replies: 10
    Last Post: 11-24-2010, 05:00 PM
  3. String matching a pattern
    By vividcooper in forum New To Java
    Replies: 7
    Last Post: 01-07-2010, 11:30 PM
  4. Replies: 1
    Last Post: 10-27-2009, 08:33 PM

Posting Permissions

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