Legal input for resource pattern

What kinds of patterns are supposed to be accepted in the compiler
resource patterns field? The initial contents look like this

?.properties;?.xml;?.html;?.dtd;?.tld;?.gif;?.png;?.jpeg;?*.jpg

Is this supposed to be a semicolon-separated list of regular
expressions? Because "?*.properties" is not a legal regular expression.

The Help says to "provider here a regular expression" and gives the example

-.+\.(properties|gif|png|jpeg|xml)

which is legal, but seems unlikely to be correct, because it would
require a file name to have a leading "-". I've tried entering

.+\.(dat|gif|html|ico|jpg|png|policy|zip)

but nothing gets copied. It looks to me like this field wants file
globbing patterns, not full-featured regular expressions, which is
unfortunate and contrary to the documentation. Which is it intended to be?

5 comments

+1

I've also observed the same issue when attempting to use a legal regex:
"^.+
.(txt|xml)"

The following code proves that the above expression is valid for Java regular expressions:

import java.util.regex.Pattern;

public class RegexTest {
public static void main(String[] args) {
String[] all = new String[]{"foo.txt", "foo.xml", "foo.doc"};
String r = "^.+
.(txt|xml)";
for (String s : all) {
if (Pattern.matches(r, s)) {
System.out.format("regex %s matched %s\n", r, s);
}
}
}
}
}

0

Any chance of getting an answer to this question? It seems simple enough.

0

Hello Michael,

the help about the format of the compiler resource pattern used to be wrong (and still seems wrong
in the latest 7.0.3 EAP). The correct pattern syntax is not based on regular expressions, but a
semicolon-separated list of patterns with * and ? as wildcards: "* denotes any number of any
characters, ? stands for any single character":

?.properties;?.xml;?.html;?.dtd;?.tld;?.gif;?.png;?.jpeg;?*.jpg

This matches all files with the specified extensions which have at least one character before the dot.

HTH,
Sascha

0

Come on Jetbrains, let's get this fixed. We pay good money for this tool.

I did a quick search in the IDEADEV Jira for "resource pattern regex":

IDEADEV-23194 Resource patterns aren't patterns FIXED
IDEA-6493 Help text wrong for Compiler -> resource patterns FIXED

Are these REALLY fixed? (no, at least not in 7.0.2).

We want real regex expressions as advertised in the Help!

Dan

0

Please sign in to leave a comment.