I have this code in my functions.php file:

```
function user_content_replace($content) {

    // it's not a URL, let's apply the replacement
    if (!filter_var($string, FILTER_VALIDATE_URL)) {
        $replacement = '$1.</p><p>$2';
        return preg_replace("/([^\\.]*\\.[^\\.]*\\.[^\\.]*){1}\\.([^\\.]*)/s", $replacement, $content);
    } else { // it's a URL, just return the string
        return $content;
    }
}
add_filter('the_content','user_content_replace', 99);

```

This code replaces every third dot in content with dot+closed+open paragraph. This because it is the best way in this moment to format non-formatted great amount of texts and posts.

But: this code also changes **Images URLs** so all my images does not contain dot before extension but `**imagename.</p><p>jpg**`instead of **imagename.jpg**

Even if I put URL validation - same problem. Any advice please?