Show fields that match the criteria

Source: Internet
Author: User
String:
Tkpc10090987tkpc10098m9ytkmr120990u9tkmr10059e56

Requirements:
1, interception of each tkpc and TKMR after the continuous 5-digit number. (Examples of interception should be tkpc have 11090,12098,TKMR have 12099,11059)
2, after the interception of the number according to the following conditions, for the true echo Yes.
2.1 TKPC Two sets of numbers, if there is less than or equal to 11069, echo satisfies the condition for each group of tkpc+ after 8 bits.
2.1 TKMR Two sets of numbers, if there is less than or equal to 10999, echo satisfies the condition for each group of tkmr+ after 8 bits.


Reply to discussion (solution)

$str = "tkpc10090987tkpc10098m9ytkmr120990u9tkmr10059e56"; for ($i = 0, $len = strlen ($STR); $i < $len; $i + +) {    if (s Ubstr ($str, $i, 4) = = ' tkpc ') {        if (substr ($str, $i +4, 5) <= 11069) {            echo ' tkpc '. substr ($str, $i +4, 8). "\ n";        }    }    if (substr ($str, $i, 4) = = ' Tkmr ') {        if (substr ($str, $i +4, 5) <= 10999) {            echo ' tkmr '. substr ($str, $i +4, 8). "\ n";}}    }


Tkpc10090987tkpc10098m9ytkmr10059e56
  • 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.