How to test if a string is a substring of any instance of a regex? -
in programming language , library,
how can test if string substring of instance of regular expression?
for example, instances of regex
ra = /^a{1,2}c{1,2}$/
are
'ac', 'acc', 'aac', 'aacc'.
the string 'cc' not instance of regex substring of 2 instances of regex. how can test 'c' has such property?
equivalently, how can (in general) regex instances substrings of instances of regex.
for example above, regex
rb = /^a{0,2}c{0,2}$/
has instances
'', 'c', 'cc', 'a', 'ac', 'acc', 'aa', 'aac', 'aacc'
which substrings of instances of ra.
how can calculate such rb ra regex ra?
thanks in advance!
if mean computer science regular expression, can forming alternation of subsequences of tokens:
/^a{1,2}c{1,2}$/ -> /^(a{1,2}|a{1,2}c{1,2}|c{1,2}|)$/
note grow in length o(n2) n number tokens in original expression.
Comments
Post a Comment