Q:

Cannot match my regular expression

I am trying to match a string that looks like "WIFLYMODULE-xxxx" where the x can be any digit. For example, I want to be able to find the following...
WIFLYMODULE-3253
WIFLYMODULE-1585
WIFLYMODULE-1632
I am currently using 
final Pattern q = Pattern.compile("[WIFLYMODULE]-[0-9]{3}");

but I am not picking up the string that I want. So my question is, why is my regular expression not working? Am i going about it in the wrong way? 

A:

You should use (..) instead of [...]. [..] is used for Character class
With a "character class", also called "character set", you can tell the regex engine to match only one out of several characters. 
(WIFLYMODULE)-[0-9]{4}

Here is demo
Note: But in this case it's not needed at all. (...) is used for capturing group to access it by Matcher.group(index)

Important Note: Use \b as word boundary to match the correct word.
\\bWIFLYMODULE-[0-9]{4}\\b

Sample code:
String str = "WIFLYMODULE-3253 WIFLYMODULE-1585 WIFLYMODULE-1632";
Pattern p = Pattern.compile("\\bWIFLYMODULE-[0-9]{4}\\b");
Matcher m = p.matcher(str);
while (m.find()) {
    System.out.println(m.group());
}

output:
WIFLYMODULE-3253
WIFLYMODULE-1585
WIFLYMODULE-1632

