How to write a number with a specified length for regular expression matching?

Source: Internet
Author: User
How do I write a number with the specified length for regular expression matching? & Lt; td & gt; 1234567890 & lt; td & gt; 1234567890123 & lt; td & gt; 0987654321 & lt; td & gt; 3210987654321 & lt; td & gt; 1324354657 & lt; td & gt; & how do I write a number with the specified length for regular expression matching?
1234567890
1234567890123
0987654321
3210987654321
1324354657
1324354657689
I only want to match the numbers with a length of 10. how do I write regular expressions?

------ Solution --------------------
PHP code
$ Str = <
  
   
123456789012345678901230987654321321098765432113243546571324354657689Htm; preg_match ('/([\ D] {10} <\/td>)/', $ str, $ match); print_R ($ match [1]);
   
------ Solution --------------------
PHP code
     123456789012345678901230987654321321098765432113243546571324354657689Htm; preg_match_all ('/([\ D] {10} \ B <\/td>)/', $ str, $ match); print_R ($ match [1]);
------ Solution --------------------
PHP code
Preg_match_all ('/(\ D {10} \ B) <\/td>/', $ str, $ matchs); print_r ($ matchs );
------ Solution --------------------
Change the function to preg_match_all.

Preg_match_all ('/([\ D] {10} <\/td>)/', $ str, $ match );

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.