I wish to replace first word in title to possess <span></span> inside.

Example for Wordpress title

<h2 class="entry-title"><a href="#">Welcome to Wordpress</a></h2>

I wish to end up like this

<h2 class="entry-title"><a href="#"><span>Welcome</span> to Wordpress</a></h2>

the function

function span_on_title($span) {
 return preg_replace('', '', $span, 1);

May i understand what to use the preg_replace

  $title = '<h2 class="entry-title"><a href="#">Welcome to Wordpress</a></h2>';

  $title = preg_replace('/<a([^>]+)>([a-zA-Z]+)\s/i', '<a$1><span>$2</span> ', $title);

  return $title;