Example of the simple input Regular Expression verification function implemented by the Applet: input Regular Expression
This example describes how to implement simple input Regular Expression verification in a applet. We will share this with you for your reference. The details are as follows:
1. Effect display
2. Key code
Index. wxml File
<Input placeholder = "input content" bindinput = "check"> </input> <view> input result: {result }}</view>
Index. js File
Page ({data: {result: ''}, check: function (e) {var regLowerCase = new RegExp ('[a-z]', 'G '); // determine whether the user input is a lowercase letter var regCapitalLetter = new RegExp ('[A-Z]', 'G '); // determine whether the input is an uppercase letter var regNum = new RegExp ('[0-9]', 'G '); // determine whether the user inputs a number var rslowercase1_reglowercase.exe c (e. detail. value); var rsCapitalLetter=regCapitalLetter.exe c (e. detail. value); var rsnum1_regnum.exe c (e. detail. value); if (rsLowerCase) {this. setData ({result: 'The lower-case letter you entered '})} else if (rsCapitalLetter) {this. setData ({result: 'Your input is an uppercase letter '})} else if (rsNum) {this. setData ({result: 'Number you entered '})} else {this. setData ({result :''})}}})
3. Click here for the complete instance codeDownload from this site.
PS: here we will provide two very convenient Regular Expression tools for your reference:
JavaScript Regular Expression online testing tool:
Http://tools.jb51.net/regex/javascript
Regular Expression generation tool:
Http://tools.jb51.net/regex/create_reg
I hope this article will help you develop small programs.