开发者

How to retrieve number using regex and preg_match in php

开发者 https://www.devze.com 2023-01-31 17:13 出处:网络
I am trying to retrieve the ten digit id number from a textarea. e.g id no 1234567890 I was trying to use.

I am trying to retrieve the ten digit id number from a textarea.

e.g id no 1234567890

I was trying to use.

preg_match("/('/^[0-9]{10}/')/", $article, $tags);

But it does not work. I 开发者_开发技巧appreciate any help.

Thanks.


Try:

preg_match_all("/\d{10}/", $article, $tags);


preg_match('/[0-9]{10}/', $article, $tags);

Try that. Or if you have multiple IDs, you can use preg_match_all.

preg_match_all('/[0-9]{10}/', $article, $tags);
0

精彩评论

暂无评论...
验证码 换一张
取 消