Fix bug in output ref renaming

http://manage.dimagi.com/default.asp?147618
The new part here is the `-` at the end. Also used `\w` to match the expression used by `isValidElementName`.