Use regular expressions to replace text with HTML tags starting with a certain character.
P粉438918323
2023-07-27 14:06:49
<p>I need to convert text into HTML tags, like this: </p>
<pre class="brush:php;toolbar:false;">input: p1: Question 1
output: <h3>Question 1</h3></pre>
<p>or</p>
<pre class="brush:php;toolbar:false;">input: question 1: ¿ question 1?
output: <h3>¿ question 1?</h3></pre>
<p>The detail I don't understand is that I have the following regex rule. </p>
<pre class="brush:php;toolbar:false;">([a-zA-Z])([1-9])(:) (.*)?</pre>
<p>And my result is:</p>
<pre class="brush:php;toolbar:false;"><h3> Question 1</h3>
question 1: ¿ question 1?</pre>
<ul>
<li>In the first example, I need to remove the space generated between <h3> and Q. <code></code></li>
<li>In the second example, it doesn't work at all for me. </li>
</ul>
<p>Can you help me see where I'm going wrong in my regex rules? </p><p>Demo:</p><p><strong></strong></p>
the answer is