I must filter the publish and page content to append html tags to a particular content just before saving this content towards the database.

For instance, given a keyword "Red-colored Yoga Mats", I must scan the page/publish content and replace the very first demonstration of "Red-colored Yoga Mats" with <b>Red Yoga Mats</b> and replace the 2nd instance with <i>Red Yoga Mats</i> and also the 3rd instance with <u>Red Yoga Mats</u>.

How difficult would this be?

(The saying "Red-colored Yoga Mats" is arbitrary. Let me place this like a dynamic variable which i would pass towards the filter function that does this content append)

it might be less complicated for a moment get this to alternation in moment, when publish isn't saved, but displayed (within this situation make use of the_content filter hack) but when you want to create changes when publish is saved, use action hack save_publish. some pseudo code:

add_action('save_post', 'my_func');
    function my_func($post_ID) {
    // retrive content of post based on $post_ID
    // use str_replace to replace things
    // save post again

You could utilize a filter on the_content with this.

add_filter( 'the_content', 'highlight_red_yoga_mats' );
function highlight_red_yoga_mats($content) {
    // modify $content here
    return $content;