Intersection of two regular expressions

后端 未结 4 1650
忘了有多久
忘了有多久 2020-12-17 18:05

Im looking for function (PHP will be the best), which returns true whether exists string matches both regexpA and regexpB.

Example 1:

$regexpA = \'[0         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 18:19

    It is possible. I encountered it once with Pellet OWL reasoner while learning semantic web technologies.

    Here is an example that shows how regular expressions can be parsed into a tree structure. You could then (in theory) parse your two regular expressions to trees and see if one tree is a subset of the other tree, ie. if one tree can be found in within other tree's nodes.

    If it is found, then the other regular expression will match (not only, but also) a subset of what the first regular expression will match.

    It is not much of a solution, but maybe it'll help you.

提交回复
热议问题