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.
About Question enthuware.ocpjp.v7.2.1628 :
Moderators: Site Manager, fjwalraven
-
- Posts: 77
- Joined: Sun Jun 30, 2013 10:04 pm
- Contact:
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1628 :
Yes, that is correct. You may go through the details here: https://docs.oracle.com/javase/tutorial ... .html#glob
-
- Posts: 29
- Joined: Wed Apr 17, 2013 9:22 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1628 :
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.
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.
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1628 :
Enhanced the explanation.
thank you for your feedback!
Paul.
thank you for your feedback!
Paul.
Who is online
Users browsing this forum: No registered users and 3 guests