Summary of PHP Regular Expressions

Source: Internet
Author: User
Welcome to the Linux community forum. You can only enter the number 19functiontest_shuzi (strshuzi) {20varmyReg ^ [0-9] * $; 21if (myReg. test (strshuzi) returntrue; 22 returnfalse; 23} 24 can only input 25functiontest_han

Welcome to the Linux community forum and interact with 2 million technical staff> enter 18 // you can only enter the number 19 function test_shuzi (strshuzi) {20 var myReg =/^ [0-9] * $/; 21 if (myReg. test (strshuzi) return true; 22 return false; 23} 24 // only 25 Chinese characters can be entered. function test_han

Welcome to the Linux community forum and interact with 2 million technicians>

18

// Only numbers can be entered

19

Function test_shuzi (strshuzi ){

20

Var myReg =/^ [0-9] * $ /;

21

If (myReg. test (strshuzi) return true;

22

Return false;

23

}

24

// Only Chinese characters can be entered

25

Function test_hanzi (strhanzi ){

26

Var myReg =/^ [\ u4e00-\ u9fa5] {0,} $ /;

27

If (myReg. test (strhanzi) return true;

28

Return false;

29

}

30

Script

31

  

32

  

33

  

37

  

38

  

[1] [2]

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.