Both issues are addressed by options in my Text Toolbox:
You can adapt the code to your issues, of course.
For more information, see the wiki Searching the Forum for Answers section.