Ask PHP to use a regular expression. in this case

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.