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.