How do you insert a string before a number?
I have the following WordPress function:
get_the_term_list( $post->ID, 'level', '', ', ', '' )
This function outputs numbers like so:
<a href="#">1</a>
or, if there is more than one entry in the database:
<a href="#">1</a>, <a href="#">2</a>
How can I insert “level ” before the number? so that it looks like this:
<a href="#">level 1</a>
Or:
<a href="#">level 1</a>, <a href="#">level 2</a>
You simply match the number. In a regex
\d+can be used for decimals.And you can just use
>and<anchors. Here$1reinserts the found decimal.