Set<String> (Project project, @NotNull String regExp) { final PsiFileFactory factory = PsiFileFactory.getInstance(project); final PsiFile file = factory.createFileFromText("dummy.regexp", RegExpFileType.INSTANCE, regExp); final RegExpPattern pattern = (RegExpPattern)file.getFirstChild(); if (pattern == null) { return null; } final RegExpBranch[] branches = pattern.getBranches(); final Set<String> values = new HashSet<>(); for (RegExpBranch branch : branches) { if (analyzeBranch(branch)) { values.add(branch.getUnescapedText()); } } return values; }