The mathematical concept of "distance" is quite broad but then again rigorously defined. In general the distance function (or metric) has to have certain properties. The Levenshtein Distance (LD) is a metric for measuring the "amount" of difference between two strings.

In your case the question is different. You don’t compare two strings but a string and a glob. By definition this is not possible unless the glob results in one string only. Otherwise the LD is simply not defined.

In the example you give: you suggest that LD(*cxd*,adcdef)=1. But this is only so when *cxd* expands into one string only which is one edit operation away from adcdef.

Maybe you could generalize the distance function for your particular application. It might not be a proper distance function anymore but may still be useful depending on your particular problem. After expanding the glob into {s1, s2, …, sn} you could determine the LD for all those strings with the original string: {d1, d2, …, dn}. Depending on what meaning it has to you, I don’t know the particular application of it, you can then take the lowest, highest, average or whatever value that makes sense to you.

I wonder what the particular application is you're after.


In reply to Re: Edit distance between regular expression by dHarry
in thread Edit distance between regular expression by future.open

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.