No need to use regex. This will do it:
$extension_pos = strrpos($filename, '.'); // find position of the last dot, so where the extension starts
$thumb = substr($filename, 0, $extension_pos) . '_thumb' . substr($filename, $extension_pos);
More Related Contents:
- PHP – How do I convert string number to number [closed]
- Regex pattern can't figure out
- How do you implement a good profanity filter?
- preg_match(): Compilation failed: invalid range in character class at offset
- How to add http:// if it doesn’t exist in the URL
- Right way to escape backslash [ \ ] in PHP regex?
- “Unknown modifier ‘g’ in…” when using preg_match in PHP?
- How to validate domain name in PHP?
- Optional Whitespace Regex
- How to replace text URLs and exclude URLs in HTML tags?
- How to split a string by multiple delimiters in PHP?
- Convert string into slug with single-hyphen delimiters only
- Get domain name (not subdomain) in php
- Get numbers from string with PHP
- PHP Regex find text between custom added HTML Tags
- Function eregi() is deprecated [duplicate]
- regex matching links without tag
- Split string into sentences using regex
- How to search in an array with preg_match?
- Regex & PHP – isolate src attribute from img tag
- Regex for checking if a string has mismatched parentheses?
- Replace tabs and spaces with a single space as well as carriage returns and newlines with a single newline
- How to validate a domain name using Regex & PHP?
- PHP regex for validating a URL
- Test if a string is regex
- Request exceeded the limit of 10 internal redirects
- How do I replace characters not in range [0x5E10, 0x7F35] with ‘*’ in PHP?
- PHP regex templating – find all occurrences of {{var}}
- Regex ignore URL already in HTML tags
- Detecting a url using preg_match? without http:// in the string