I have the following string: ====== Text ======. As the number of the = characters may be from 2 to 6 on both sides of the text. I want to insert a dash like this: ====== -Text ======.
For this purpose I use the following code:
Code: Select all
$pattern = "/(={2,6})(.+?)(={2,6})/";
$replace = '$1 -$2$3';
$content = preg_replace($pattern, $replace, $content);
I want to add dashes only when there is text between =(equal signs)
Regards!