If you prefix your regex with the modifier
(?x) you can add white space without changing the meaning, making the regex (perhaps) somewhat easier to read:
Code: Select all
(?x) (?<=[ \t]) \b IIMeta \b \s* \( \s* \b (\w+) ( | (?:<[?\w ]+>) | (?:<[^<]*<[?\w ]+>[^>]*>) | (?:<[^<]*<[^<]*<[?\w ]+>[^>]*>[^>]*>) ) \s+ (\w+) \b (?!>) \s* \)
For the sake of simplicity, remove the Java template stuff, which isn't required in your example:
Code: Select all
(?x) (?<=[ \t]) \b IIMeta \b \s* \( \s* \b (\w+) \s+ (\w+) \b (?!>) \s* \)
It is now apparent that the word boundary anchors (
\b) are redundant, and can be removed:
Code: Select all
(?x) (?<=[ \t]) IIMeta \s* \( \s* (\w+) \s+ (\w+) (?!>) \s* \)
As can the
(?!>) look-ahead:
Code: Select all
(?x) (?<=[ \t]) IIMeta \s* \( \s* (\w+) \s+ (\w+) \s* \)
And some parentheses:
Code: Select all
(?x) (?<=[ \t]) IIMeta \s* \( \s* \w+ \s+ \w+ \s* \)
It is now clear that your regex matches the function name and its single parenthesised typed parameter.
I don't see anything wrong.
(By the way, the expression
(?<=[ \t]) is a look-behind assertion, not a back-reference.)