A brief analysis of the specific use of PHP function ereg () _php Tutorial

Source: Internet
Author: User
Tags ereg
In many high-level languages,Syntax: int ereg (string pattern, string string, array [regs]);

return value: Integer/array

Function type: Data processing

php function Ereg () content description

This function parses string strings with the rule of pattern. The value returned from the result is placed in the array parameter regs, Regs[0] content is the original string, string, Regs[1] is the first rule of the string, Regs[2] is the second rule of the string, and so on. If the parameter regs is omitted, it is simply a comparison, and the return value is true if found.

php function Ereg () Usage Example

Simple example:

 
  
  
  1. < ? PHP
  2. if (Ereg ("C", "abcdef")) {
    Description: Determine if the abcdef contains the letter C
  3. echo "Pass";
  4. }else{
  5. echo "Error";
  6. }
  7. ?>

The following PHP function Ereg () example is to enter the e-mail to make a simple check, check whether the user's e-mail string has an @ character, before the @ character has an English letter or number, after a few strings, the last decimal point can only have two or three English letters. Super@mail.wilson.gs can pass the inspection, Super@mail.wilson cannot pass the examination.

 
  
  
  1. < ? PHP
  2. if (Ereg ("^[_.0-9a-z-]+@ ([0-9a-z]
    [0-9a-z-]+.) +[a-z]{2,3}$ ", $email))
  3. {
  4. echo "Your e-mail through a preliminary check";
  5. }
  6. ?>


http://www.bkjia.com/PHPjc/446312.html www.bkjia.com true http://www.bkjia.com/PHPjc/446312.html techarticle in many high-level languages, Syntax: int ereg (string pattern, string string, array [regs]), return value: Integer/Array function type: Data processing PHP function ereg () content description This function with ...

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