7
I don’t have much knowledge of regex, so I got this rule ready.
$break_title = preg_replace('/(?<=\>)\b\w*\b|^\w*\b/', '<span>$0</span>', $title);
return $break_title;
The problem is that it does not recognize the cedilla, so the string below:
construções importantes
Stay like this:
<span>constru</span>ções importantes
Can you explain what the pattern is? What are the values that
$title
can have? The special and particular characteristics of each language do not really fit in the regex that has.– Sergio
@Sergio Title values will be dynamic. So I have to predict the use of accented letters and with cedilla.
– marcelo2605
Have you tested
\p{L}
?– Sergio
@Sergio Which part should I replace?
– marcelo2605
Perhaps this is enough: http://ideone.com/ABs2z5 is what you are looking for?
– Sergio
@Sergio worked! And it was much simpler huh. Put as answer.
– marcelo2605