Can't you adapt the macro provided to you here:
For more information, see the wiki Searching the Forum for Answers section.