Why is the PHP regular match unsuccessful? Help

Source: Internet
Author: User
Regular PHP

if (Preg_match ("^[a-za-z][a-za-z0-9_\-]{5,19}$", "abc-mmm"))
echo "true";
else echo "false";

?>

Want to verify the regular expression of the account, the beginning of the letter, allow numbers, letters, underscores, minus, 6-20 for, why the expression is not successful AH?

Warning:preg_match () [Function.preg-match]: No ending delimiter ' ^ ' found in test.php on line 3
False

Tried "^[a-za-z][a-za-z0-9_-]{5,19}$", take off "\" is not right, ask God to know (UTF8 format)


Reply to discussion (solution)


Preg_match ("/^[a-za-z][a-za-z0-9_-]{5,19}$/", "Ml-virgil"))


Just tried to add "/" on the line, this is why? I am a novice php do not understand, seek the guidance of the Great God

That's called the delimiter. Without delimiters, PHP would assume that ^[a-za-z][a-za-z0-9_-]{5,19}$ is a string, not a variable.

We often call "\" called "Skipping character", which is used to escape some special symbols.

That's called the delimiter. Without delimiters, PHP would assume that ^[a-za-z][a-za-z0-9_-]{5,19}$ is a string, not a variable. So ah, that ask the big God a question, I put the English and Chinese with "\ n" connected to the mysql,php code and MySQL are utf-8 why in Phpadmin found is "0", data type is text? Troubled me for a long time ah ...

Done, the SQL statement problem, really careless. Knot sticker, please.

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