📜  血型正则表达式 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:38.055000             🧑  作者: Mango

代码示例1
const validBloodGroupRegex = /^(A|B|AB|O)[+-]$/i; // Here i is to ignore case sensitivity
const validBloodGroupString = 'AB+';
const invalidBloodGroupString = 'BC+';

// Returns true
console.log(validBloodGroupRegex.test(validBloodGroupString))

// Returns false
console.log(validBloodGroupRegex.test(invalidBloodGroupString))