Home > Web Front-end > Vue.js > body text

Can vue.js use regular expressions?

藏色散人
Release: 2023-01-13 00:45:04
Original
3026 people have browsed it

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]".

Can vue.js use regular expressions?

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]
Copy after login

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]
Copy after login

3. A positive integer that cannot be zero is required

this.taskInfo.fbday = (fbday.match(/^([1-9]*)/g)[0]) || null
/^([1-9]*)/g)[0]
Copy after login

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
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template