Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

This is probably a pretty newbie-ish question, but I've tried everything I can think of so far for this problem, and I've decided to beg for the help of the great monks. ;)

Basically what I'm doing is, I want to have a function that will take two strings and compare them, returning a percentage of differences between string A and string B. This is pretty easy if you assume they will be the same length and simply want to compare character by character, but I'll be working with strings of varying lengths.

For example, if string A is "this is a really annoying piece of text" and string B is "a really annoying piece of text" a character-by-character comparison would work very poorly for indicating how similar the strings are for the most part.

Anyway, I was wondering what might be good approaches for doing this sort of comparison, so that I can get fairly accurate ideas of how one string relates to another in this project I'm working on.

Thanks in advance for any help


In reply to Comparing Strings by Segfault

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2023-01-30 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?