What is the problem about formvalidtor's regular expression writing in thinkphp ?? Help

Source: Internet
Author: User
What is the problem about formvalidtor's regular expression writing in thinkphp ?? We help use formValidator-4.1.3.js for email format check.
The writing method is as follows.

$ ("# Email "). formValidator ({onShow: "Please enter your email address", onFocus: "mailbox 6-characters, enter the correct information to exit the focus", onCorrect: "Congratulations, you have entered the correct information", defaultValue: "@"}). inputValidator ({min: 6, max: 100, onError: "The email you entered is invalid. please confirm "}). regexValidator ({regExp: "^ ([\ w-.] +) @ ([0-9] {1, 3 }. [0-9] {1, 3 }. [0-9] {1, 3 }.) | ([\ w-] + .) +) ([a-zA-Z] {2, 4} | [0-9] {1, 3}) (]?) $ ", OnError:" The email format you entered is incorrect "});


The test is normal on the static webpage. However, in the thinkphp template file, the parsed code becomes
RegExp: "^ ([\ w-.] +) @ ([0-9] {1, 3 }. [0-9] {1, 3 }. [0-9] {1, 3 }.) | ([\ w-] + .) +) ([a-zA-Z] {2, 4} | [0-9] {1, 3}) (]?) $"

The formValidator message "the operator set is out of bounds" is reported.

Why is the expression changed. \ W changed to \ w?
Please help confirm it!


Reply to discussion (solution)

The template file will be read into the variable, so \ w becomes \ w
Write \ w or \ w

Thank you for your reply. After performing the preceding modification, OK.
I have some questions.

RegExp: "^ ([\ w-.] +) @ ([0-9] {1, 3 }. [0-9] {1, 3 }. [0-9] {1, 3 }.) | ([\ w-] + .) +) ([a-zA-Z] {2, 4} | [0-9] {1, 3}) (]?) $"

There are two \ WS in the expression. why is the previous \ w converted to \ w, and the subsequent \ w remains unchanged?

This is not clear. you need to check the C source code of php to analyze the cause.
But not everyone can do this.
In actual use, you do not need to go into it. if you add a "\" when it is not running, you need to add another one, so that the loop knows that there is no error.

You can see that there are four or five lines of code in foreign countries.

It is possible that thinkphp only transforms the First \ in the string during template parsing, and the subsequent values are processed as strings.
Thank you.

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.