String str = "Array is the most #important thing in any programming #language";
Pattern MY_PATTERN = Pattern.compile("#(\\w+)");
Matcher mat = MY_PATTERN.matcher(str);
while (mat.find()) {
System.out.println(mat.group(1));
}
The regex used is:
# - A literal #
( - Start of capture group
\\w+ - One or more word characters
) - End of capture group