I have three line of code that calculate the length of characters put between < and > in a string submitted by a user.
$Msg = '<Part1>Hello!<Part2>Hello again!<Part3>';
preg_match_all('/<([^>]*)>/', $Msg, $msglenght);
$msglenght = mb_strlen(join($msglenght[1]), 'UTF-8');
echo $msglenght;
The lines work fine, but as I'm putting them in a program that has user submitted special characters converted, I need to alter the regex line to:
preg_match_all('/<([^>]*)>/', $Msg, $msglenght);
But now, if a user uses the semicolon (;) in a submitted string, the program doesn't calcolate the number of characters correctly. I don't know practically anything about regex, how the line should be changed to having the semicolon properly escaped?