Producing all possible matches of a regular expression

后端 未结 1 1219
日久生厌
日久生厌 2021-01-18 12:29

Given a regular expression, I want to produce the set of strings that that regular expression would match. It is important to note that this set would not be infinite becau

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-18 12:46

    Are there any well known algorithms in place to do this?

    In the Perl world we have a module on CPAN that does just that -> Regexp::Genex

    A recursive algorithm is described here , several libraries that do this in Java are mentioned here.

    Are there any research papers I could read to gain insight into this problem?

    Yes, the following papers are available for counting the strings that would match a regex (or obtaining generating functions for them):

    1. Counting occurrences for a finite set of words: an inclusion-exclusion approach by F. Bassino, J. Clement2, J. Fayolle, and P. Nicodeme (2007) paper slides
    2. Regexpcount, a symbolic package for counting problems on regular expressions and words by Pierre Nicodeme (2003) paper link link code

    0 讨论(0)
提交回复
热议问题