I need to convert the following python regexp to java regexp:
regexp = re.compile(r"^(?P<prefix>(%s)(%s)?)\s?\b(?P<name>.+)" %
("|".join(array1),
"|".join(array2)), re.IGNORECASE
| re.UNICODE)
where array1 and 2 are arrays of strings.
What I did is:
String regexp = String.format("^(?<prefix>(%s)(%s)?)\\s?\\b(?<name>.+)", array1, array2);
regexpPattern = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE);
But I get a PatternSyntaxException: "Unknown look-behind group near" in the question mark of (%s)(%s)?
I don't understand very well this question mark.
Any suggestion on how to translate it into Java 1.6?