A simple matching problem

Source: Internet
Author: User
A simple matching problem ----------- text ----------------- Name1ABCName2ABCName3ABC ------------- text ----------------- A, B, and C are three simple matching problems.
------------- Text ---------------

Name1 A B C
Name2 A B C
Name3 A B C

------------- Text ---------------


A, B, and C are three random numbers. Sometimes A number is null (that is, it becomes Name1 A C ), how can I obtain the value of ABC in any situation?
Thank you!

------ Solution --------------------
PHP code
$ S = <TXTName1 a B CName2 A CName3 a B CTXT; preg_match_all ('/([ABC] +) \ s + ([ABC] *) \ s + ([ABC] *) \ s * $/M', $ s, $ r); print_r ($ r );
------ Solution --------------------
Hey...

A. php
------------- Text ---------------

Name1 11 23 14
Name2 43 33
Name3 30 44 2

------------- Text ---------------
B. php

$ File = "a. php"; // variable assignment
$ Fp = fopen ($ file, "r"); // open the file in read-only mode
$ I = 0; // I = 0
While (! Feof ($ fp) {// while loop, condition: not to the end of the file.
$ Buffer = fgets ($ fp, 4096); // The fgets () function is used to read files row-by-row from files, the number of bytes read. The default value is 1024 bytes.
Preg_replace ('/+/', '', $ buffer );
Preg_match_all ('/([0-9] +)/', $ buffer, $ matches );
If (! Empty ($ matches [1]) {
Print_r ($ matches [1]);
}
$ I = $ I + 1; // uses the while loop to increase the I value and build an array.
}
Fclose ($ fp); // close the file.
?>
------ Solution --------------------
In fact, I think there is another big question! Because LZ requires numbers and letters, such:
Text:
Name1: 11 32
What I finally got is
PHP code
Array(     [0]=11     [1]=     [2]=32)
Related Article

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.