Baptiste asked...
I've modified it to /\ref{\s*}+(\s.*)$/i in order to get a comment as well, although it gives me the whole paragraph. Is there any way to limit the number of following words to, say, 10
Good point: sorry I'd missed the "Comment" business.
Sure, you can limit the output: if you use, say,
/\ref{\s*}((\s*\w+){0,10})/
you should get *up to* ten words after the empty ref.
Cheers, Paul