easiest way to align/match two strings?

Discussion in 'OT Technology' started by prech, Sep 29, 2004.

  1. prech

    prech New Member

    Joined:
    Jun 4, 2004
    Messages:
    362
    Likes Received:
    0
    Coding newb here, I'm trying to align 2 strings of, say, all uppercase characters, what would be the easiest way to compare and count all matches?

    Say, for 'ABCDEF' and 'AKBDF', on a one to one match basis, A and D would be hits (when position within the string is respected). I'm working with Perl and currently using a parsing scheme (if string1[counter] == string2[counter], counter++, etc), but is there an easier way?

    Of note is that as my script expands, I don't know how well it'll handle increasing window sizes (ie. for a 20 character string, a window size of 3 means only 3 characters are compared against 3 characters at the same positions in the opposing string), while introducing a mismatch threshold (say, in the window size of 3, 1 mismatch is allowed and the hit would still score)
     
  2. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    not sure what you're asking.. align?

    to count (in c), simply...

    l=strlen(a);
    if (strlen(b)<l) l=stren(b);
    matches=0;
    for(i=0;i<l;i++) if (a==b[j]) matches++;
     

Share This Page