Regular Expression function library: Ereg

Source: Internet
Author: User
Keywords ereg php Chinese function Handbook regular expression function library
Tags aliyun array date expression function function library html http

Ereg

(PHP3, PHP4)

Ereg---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Formal expression comparison

Syntax: int ereg (string pattern, string string [, array regs])

Description:

Search string to show the normal representation of pattern.

If a match is found, the third parameter regs is called, and the result of the comparison is stored in the regs element, $regs [1] is a partial string that conforms to the first left bracket (parenthesis), $regs [2] is a partial string that conforms to the second bracket, and so on, $regs [ 0] is an argument string.

If Ereg () finds the alignment, the $regs is filled with 10 elements, even if it is more than or less than 10 parentheses, and can be compared, which does not affect the ability of ereg () to compare to more partial strings. If you do not, $regs will not be ereg () change.

Search is case-sensitive.

Returns True if the string is more than pattern, and returns false if it is less than or if an error occurs.

The following example cuts the date format yyyy and displays it as a DD.MM.YYYY format.

Example:

<?php

if (Ereg ([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}), $date, $regs)) {

echo "$regs [3]. $regs [2]. $regs [1]";

}

else {

echo "Invalid date format: $date";

}

?>

Reference: Eregi () ereg_replace () eregi_replace ()

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.