String comparisions

Discussion in 'Ruby' started by Talib Hussain, Feb 12, 2009.

  1. Experts,

    I have a requirement of comparing string and getting the difference out

    For Example :

    strOne = "Hello, this is a test"
    strTwo = "Hello, this is a test forum"

    This should result that word "forum" is extra.

    Any thoughts?

    Regards,
    Talib Hussain
    --
    Posted via http://www.ruby-forum.com/.
     
    Talib Hussain, Feb 12, 2009
    #1
    1. Advertising

  2. Talib Hussain

    Dylan Evans Guest

    [Note: parts of this message were removed to make it a legal post.]

    strTwo.split(strOne)[1].lstrip

    But that's very specific.


    On Thu, Feb 12, 2009 at 9:20 PM, Talib Hussain <> wrote:

    > Experts,
    >
    > I have a requirement of comparing string and getting the difference out
    >
    > For Example :
    >
    > strOne = "Hello, this is a test"
    > strTwo = "Hello, this is a test forum"
    >
    > This should result that word "forum" is extra.
    >
    > Any thoughts?
    >
    > Regards,
    > Talib Hussain
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >



    --
    The UNIX system has a command, nice ... in order to be nice to the other
    users. Nobody ever uses it." - Andrew S. Tanenbaum
     
    Dylan Evans, Feb 12, 2009
    #2
    1. Advertising

  3. Giampiero Zanchi, Feb 12, 2009
    #3
  4. Talib Hussain

    Alex Katebi Guest

    [Note: parts of this message were removed to make it a legal post.]

    Look into the ruby full-text search.

    On Thu, Feb 12, 2009 at 6:20 AM, Talib Hussain <> wrote:

    > Experts,
    >
    > I have a requirement of comparing string and getting the difference out
    >
    > For Example :
    >
    > strOne = "Hello, this is a test"
    > strTwo = "Hello, this is a test forum"
    >
    > This should result that word "forum" is extra.
    >
    > Any thoughts?
    >
    > Regards,
    > Talib Hussain
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >
     
    Alex Katebi, Feb 12, 2009
    #4
  5. 2009/2/12 Talib Hussain <>:

    > I have a requirement of comparing string and getting the difference out
    >
    > For Example :
    >
    > strOne = "Hello, this is a test"
    > strTwo = "Hello, this is a test forum"
    >
    > This should result that word "forum" is extra.
    >
    > Any thoughts?


    IMHO your question is by far not specific enough. What kind of output
    do you expect exactly? Do you want all _words_ reported that are
    missing or extra? Do you have to have _substrings_ reported which are
    missing or extra? Do you need _positional information_ with that? If
    so, which (word position, character position)? Do you need human
    readable output or do you want to automatically process it? etc.

    Cheers

    robert

    --
    remember.guy do |as, often| as.you_can - without end
     
    Robert Klemme, Feb 12, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. td
    Replies:
    0
    Views:
    481
  2. Mladen Adamovic
    Replies:
    0
    Views:
    741
    Mladen Adamovic
    Dec 4, 2003
  3. T Ryi

    Pointer comparisions of same type

    T Ryi, Mar 24, 2010, in forum: C Programming
    Replies:
    4
    Views:
    275
    Richard Bos
    Mar 24, 2010
  4. Eric Mahurin

    parser performance comparisions

    Eric Mahurin, Nov 4, 2005, in forum: Ruby
    Replies:
    9
    Views:
    254
    Steven Jenkins
    Nov 6, 2005
  5. Stuart Clarke

    String comparisions and counting

    Stuart Clarke, Nov 5, 2008, in forum: Ruby
    Replies:
    7
    Views:
    112
    Stuart Clarke
    Nov 5, 2008
Loading...

Share This Page