How to check whether a variable contains 5 consecutive numbers

Source: Internet
Author: User
How to check if a variable contains 5 consecutive numbers how to check if a variable contains 5 consecutive numbers, for example, $ str & quot; ads sends a lsd to lose weight at home and falls in love with the other party, and serves as a waste of money. The second doctor is under the law of 48955235, and the second teacher will immediately learn about this. & quot ;; how can I check whether the str variable contains 5 consecutive numbers (consisting of 0-9 digits? ------ solution ------------------ how can I check whether a variable contains 5 consecutive numbers in regular expression matching?
How to check whether a variable contains five consecutive numbers?
For example:

$ Str = "ads sends a lsd to lose weight when it is put at home, and falls in love with the other party, and serves as a waste of money. doctor Sada is under the law of 48955235, and the local teachers will immediately learn about it ";
How can I check whether the str variable contains 5 consecutive numbers (consisting of 0-9 digits,

------ Solution --------------------
Regular Expression Matching
PHP code
$ Str = "ads sends a lsd to lose weight when it is put at home, and falls in love with the other party, and serves as a waste of money. doctor Sada is under the law of 48955235, and the local teachers will immediately learn about it "; $ p = "/\ d {5}/I"; preg_match_all ($ p, $ str, $ result); var_dump ($ result );

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.