Home > Article > Web Front-end > Can vue.js use regular expressions?
vue.js can use regular expressions, and its usage syntax is such as "this.taskInfo.amount = (money.match(/^(0|[1-9][0-9]*)/g )[0]) || null /^(0|[1-9][0-9]*)/g)[0]".
The operating environment of this tutorial: windows7 system , vue2.5.17 version, Dell G3 computer.
Related recommendations: "vue.js Tutorial"
Regular expressions can be used in vue.js.
Regular expression
1. Requirement: Only positive integers with 0 and non-0 switches can be entered
this.taskInfo.amount = (money.match(/^(0|[1-9][0-9]*)/g)[0]) || null /^(0|[1-9][0-9]*)/g)[0]
2. Requirement: One decimal place is retained, and the first digit cannot be 0
this.taskInfo.money = (money.match(/^([1-9]*)(\.?\d{0,1})/g)[0]) || null /^([1-9]*)(\.?\d{0,1})/g)[0]
3. A positive integer that cannot be zero is required
this.taskInfo.fbday = (fbday.match(/^([1-9]*)/g)[0]) || null /^([1-9]*)/g)[0]
4. A regular expression to determine whether it is a number
var numReg = /^[0-9]*$/ var numRe = new RegExp(numReg) if (!numRe.test(number)) { this.$message({ type: 'warning', message: '请输入数字 ', duration: 10000, showClose: true, }) return false }
The above is the detailed content of Can vue.js use regular expressions?. For more information, please follow other related articles on the PHP Chinese website!