Using react-native-mask-input library from npm , I'm trying to use custom function for 12-Jun-2022 kind of date input - however this outputs only 12- , I'd appreciate it if someone can point me in the right direction
dateMask = (text) => {
const cleanText = text.replace(/\D+/g, '');
let secondDigitDayMask = /\d/;
if (cleanText.charAt(0) === '0') {
secondDigitDayMask = /[1-9]/;
}
if (cleanText.charAt(0) === '3') {
secondDigitDayMask = /[01]/;
}
let secondDigitMonthMask = /\d/;
let monthMask = /((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))/
if (cleanText.charAt(2) === '0') {
secondDigitMonthMask = /[1-9]/;
}
if (cleanText.charAt(2) === '1') {
secondDigitMonthMask = /[012]/;
}
return [
/[0-3]/,
secondDigitDayMask,
'-',
monthMask,
'-',
/\d/,
/\d/,
/\d/,
/\d/,
];
}