How to create a custom text input filter?
Take a look at the Custom Filter module.


  This module allows you to create content filter using regular expressions. Instead of creating a new module for each filter you need, now you can easily create and organize your own filters. Your filter will appear in the input format configuration page.


If you want to do it yourself in a custom module, you can implement hook_filter_info