May I ask if PHP uses a regular expression? One project may encounter the following two situations :........ SADFA: & nbsp; & lt; a & nbsp; id = "J_WSAD" & nbsp; href = "javascript: v. Can I ask PHP to use a regular expression?
The following two situations may occur in a project,
First:
... SADFA:
123
SLDKJLSKDFJ .........
Second:
... SADFA:
0
SLDKJLSKDFJ .........
Excuse me, can I use a regular expression to express it?
What I think:
Preg_match ("/SADFA :.*? (\ D +)/is ", $ text, $ reg );
In this way, we get the value 0 in javascript: void (0,
Change it to the following:
Preg_match ("/SADFA :.*? ([1-9] \ d *)/is ", $ text, $ reg );
I can get the number of the red part, but if the red part is 0, I can't help it. please help... Share:
------ Solution --------------------
$s1='........SADFA 123SLDKJLSKDFJ.........';
$s1=strip_tags($s1);
preg_match_all("/\d+/",$s1,$reg);
print_r($reg);
?>
------ Solution --------------------
$ S = <TXT
First:
... SADFA:
123
SLDKJLSKDFJ .........
Second:
... SADFA:
0
SLDKJLSKDFJ .........
TXT;
Preg_match_all ('/SADFA:. + [> \ s] (\ d +) \ B/sU', $ s, $ r );
Print_r ($ r );
Array
(
[0] => Array
(
[0] => SADFA:
123
[1] => SADFA:
0