In the NFA, it is easy to make all previously non-final states accepted so that they correspond to the language of all substrings of a given language.
In the Java regex engine, is there a way to find out if a string is a source substring of a string that matches a given regular expression?
regexX = "any beginning", regexA - any given regular expression
"regexXregexA" the resulting expression matches all substring matches of "regexA":
Example:
regexA = a*b
"a" matches
"regexXa*b"
because it is the beginning of "ab" (and "aab")
edit:
Since some people still do not understand, here is a software test for this question:
import java.util.regex.*; public class Test1 { public static void main(String args[]){ String regex = "a*b"; System.out.println( partialMatch(regex, "aaa"); ); } public boolean partialMatch(String regex, String begining){
The results are true.
source share