Preg_match related issues

Source: Internet
Author: User
Preg_match problems
Want to see if there are "Rpt_" or "Ods_" or "dw_" in the table string, and if so, take this matching string and put it in an array, I'm doing it.
$table = "S_dw_xxdf_aw_aaas";
Preg_match ('/rpt_|ods_|dw_|/i ', $table, $arr);
Print_r ($arr);
But for what, the printed array is
(
[0] = =
)


------Solution--------------------



------Solution--------------------
, the landlord's regular expression matches an empty string
Preg_match ('/rpt_
------Solution--------------------
Ods_
------Solution--------------------
Dw_/i ', $table, $arr);


------Solution--------------------
Preg_match matches the regular expression, matches only once, returns 1, otherwise 0,
Format: Preg_match ("Regular expression", "matched string", variable name that holds the result, preg_offset_capture, starting offset)
Where: Preg_offset_capture means get match index location
Start offset: Matches from the specified position
Preg_match_all--a global regular expression match that returns the total number of matches. As in the above, the difference is the match to the last.
  • 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.