Home > Article > Backend Development > Please tell me how to use regular expressions to extract the numbers in the
tag.
tag.
The website code is as follows. Please teach me how to get the four numbers 1500,0,0,0 through regular matching or other methods after file_get_contentes. Thanks for trying it myself but to no avail. I hope God can help me.
The following is what I tried without success
<code><?php header("Content-type:text/html;charset=utf-8"); $xmldata = file_get_contents("http://119977.vhost155.cloudvhost.net/data.php") $preg = '#<p>.[0-9][人]{0,}.</p>#isU'; preg_match_all($preg,$xmldata,$new_arr); print_r($new_arr); ?></code>
The website code is as follows. Please teach me how to get the four numbers 1500,0,0,0 through regular matching or other methods after file_get_contentes. Thanks for trying it myself but to no avail. I hope God can help me.
The following is what I tried without success
<code><?php header("Content-type:text/html;charset=utf-8"); $xmldata = file_get_contents("http://119977.vhost155.cloudvhost.net/data.php") $preg = '#<p>.[0-9][人]{0,}.</p>#isU'; preg_match_all($preg,$xmldata,$new_arr); print_r($new_arr); ?></code>
<code><?php $preg = '/<p>.*?(\d+).*?<\/p>/'; $str = '<p>asdff23sdfas</p>'; preg_match($preg,$str,$result); echo "<pre class="brush:php;toolbar:false">"; print_r($result);</code>
:([0-9]+)[人|人]