Pattern (@NotNull FileTemplate template, @NotNull Project project, @NotNull Int2ObjectMap<String> offsetToProperty) { String templateText = template.getText().trim(); String regex = templateToRegex(templateText, offsetToProperty, project); regex = StringUtil.replace(regex, "with", "(?:with|by)"); regex = ".*(" + regex + ").*"; return Pattern.compile(regex, Pattern.DOTALL); }