Distance between regular expression

后端 未结 6 1245
春和景丽
春和景丽 2021-02-14 14:46

Can we compute a sort of distance between regular expressions ?

The idea is to mesure in which way two regular expression are similar.

6条回答
  •  囚心锁ツ
    2021-02-14 14:58

    There are a few of metrics you could use:

    1. The length of a valid match. Some regexs have a fixed size, some an upper limit and some a lower limit. Compare how similar their lengths or possible lengths are.

    2. The characters that match. Any regex will have a set of characters a match can contain (maybe all characters). Compare the set of included characters.

    3. Use a large document and see how many matches each regex makes and how many of those are identical.

    Are you looking for strict equivalence?

提交回复
热议问题