PHP : preg_replace_callback() not working if occurrence starts with a number : I'm using **preg_replace_callback()** with a regex to pick up some heading content and create an ID based on the content but it seems that it's not working if the occurrence begins with a number and I don't understand where I'm wrong. Here is the code I'm using :

    function betterId($match){
		$escape = str_split(strip_tags($match[2]), 20);
		$id = strlen($escape[0]) >=5 ? function_to_makeItClear($escape[0]) : str_shuffle('AnyWordsHere');
		return '<h'.$match[1].' id="'.$id.'">'.$match[2].'</h'.$match[1].'>';
	}
    return preg_replace_callback('#<h([1-6]).*?>(.*?)<\/h[1-6]>#si', 'betterId', $texte);

Here is the text I want to transform

    <p>Paragraph one is okay </p>
    <h2>This will work without problem</h2>
    <p>Paragraph two is okay </p>
    <h2>This heading too</h2>
    <p>Paragraph one is okay </p>
    <h2>This item list will work too</h2>
    <p>Paragraph two is okay </p>
    <h3>1. <a href="https://www.example1.com/">This wont work</a></h3>
    <p>Paragraph one is okay </p>
    <h3>2. <a href="https://www.example2.com/">Not working</a></h3>
    <p>Paragraph two is okay </p>
    <h3>3. Neither this one</h3>
    <h3>But this works again</h3>


I would like to have something like this :

    <p>Paragraph one is okay </p>
    <h2 id="this-will-work">This will work without problem</h2>
    <p>Paragraph two is okay </p>
    <h2 id="this-heading-too">This heading too</h2>
    <p>Paragraph one is okay </p>
    <h2 id="this-item-list">This item list will work too</h2>
    <p>Paragraph two is okay </p>
    <h3 id="this-wont-work">1. <a href="https://www.example1.com/">This wont work</a></h3>
    <p>Paragraph one is okay </p>
    <h3 id="not-working">2. <a href="https://www.example2.com/">Not working</a></h3>
    <p>Paragraph two is okay </p>
    <h3 id="neither-this-one">3. Neither this one</h3>
    <h3 id="but-this-works">But this works again</h3>


Any help will be greatly appreciated