how to filter upper and lower case characters in Auto tag link code?

Question: How to filter uppercase and lowercase when the word 'tag' is written in lowercase?

and vice versa, how to filter the word 'tag' which is written in capital letters?

Here's the code I got from a plugin that hasn't been updated in a few years.

function auto_link_tags($content){

//$post_id = get_the_ID();
$post_tags = get_the_tags();

if ($post_tags) {
    $i = 0;
    foreach($post_tags as $tag) {
        $tags[$i] = ~(?:a\\s.*?/a|[^]+)(*SKIP)(*FAIL)|\\b(?:\\b( . $tag-name . )\\b(?=[^]*(|$)))\\b~i;
        $tag_url = get_tag_link($tag-term_id);
        $tag_html[$i] = 'a href=' . $tag_url . ' title=$1$1/a';
        $i++;
    }
    $content = preg_replace($tags, $tag_html, $content);
}

return $content;}

Topic request-filter filters custom-field customization Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.