Page 1 of 1

About Question enthuware.ocpjp.v7.2.1628 :

Posted: Fri Jul 17, 2015 6:34 pm
by ewebxml
Question: Why does this glob pattern

glob:?{pdf, rtf}


match only those file names that have exactly four characters ?

_________________________


I understand that ? matches exactly one character in a glob pattern.

Explanation says:
?{pdf,rtf} will match only those file names that have exactly four characters and
the last three characters have to be pdf or rtf.

Question: Is this simple addition as in

[ (? = 1 ) + (rtf = 3 )] = 4

Please confirm.

Re: About Question enthuware.ocpjp.v7.2.1628 :

Posted: Fri Jul 17, 2015 8:33 pm
by admin
Yes, that is correct. You may go through the details here: https://docs.oracle.com/javase/tutorial ... .html#glob

Re: About Question enthuware.ocpjp.v7.2.1628 :

Posted: Sat Aug 06, 2016 7:05 am
by insider
The explanation silently switches from glob syntax to Pattern/Matcher that always uses regex syntax (as far as I remember).

I suggest:
either leave current Pattern example and point out explicitly that it uses regex syntax as opposed to glob (pro: it's easier to get Pattern running for a small example than PathMatcher)
or get rid of the example and illustrate ".?pdf" regex syntax with "regex:" prefix (pro: one more opportunity to remind that there are two acceptable syntaxes for a PathMatcher)
or have both.

That's a question of explanation and is up to you, of course. Point being I didn't quite like silent transition from glob to regex syntax since they differ a lot.

Re: About Question enthuware.ocpjp.v7.2.1628 :

Posted: Sun Aug 07, 2016 7:07 am
by admin
Enhanced the explanation.
thank you for your feedback!
Paul.