in reply to Y.A.R.M.

The problem lies in the "\b" at the start and end of your regex.

See:

$_ = "ab_"; print "\\b matches\n" if m!ab_\b!; $_ = "ab*"; print "\\b matches\n" if m!ab\*\b!;
Only the first matches.

So if you change your regex to:

m@((\*|_)\S+\b)(.+?)(\b\S+\2)@s
it seems to work.