Is it possible to check if a text is fully matched by a part of regular expression?
I'd like to match text that is a prefix of (potentially) matching text.
So, for example, I have a following regex:
/etc/tomcat/conf/.*
I'd like to match all files in directory /etc/tomcat/conf/
. I can do that by matching full file name against my regex. But I need first to enter that directory, so I'd like to check if I need to enter /etc
and /etc/tomcat
in first line.
Is it possible to achieve in general case? The regex to match files will come from external system, so it's possible I'd get a regex in form:
/et..tomcat/con.*
If I understand regex machines correctly, it should be possible, because the /et..tomcat/
would be matched agaist /etc/tomcat/
, but the match will be negative because the text will and in that moment and the part con.*
would not be satisfied. I'd need only to access the internal information, that the text was fully consumed but regex not...
Do Java provides means to check that?