Regex for fiscal year
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2023 06:15 PM
What would be the regex for validating a fiscal year ?
ex: Q2FY24 or q2fy24

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2023 06:32 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2023 10:10 PM
@Prvn1 Here is the Regex to validate the fiscal year.
^Q[1-4]FY[0-9][0-9]$|q[1-4]fy[0-9][0-9]$
Please mark this answer helpful and correct if it address your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2023 12:39 AM - edited 12-03-2023 12:42 AM
Hi @Prvn1 ,
One of the Regex codes for the fiscal year validation is as below:
var pattern = /^[Qq][1-4]FY\d{2}$/i;
function validateFiscalYear(fiscalYear) {
return pattern.test(fiscalYear);
}
var fiscalYearToValidate = "Q4FY20"; // Replace with the fiscal year you want to check
if (validateFiscalYear(fiscalYearToValidate)) {
gs.info(fiscalYearToValidate + " is a valid fiscal year.");
} else {
gs.info(fiscalYearToValidate + " is not a valid fiscal year.");
}
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2023 07:23 AM
HI @Prvn1 ,
I trust you are doing great.
Please find the below regex for the same :
^[Qq][1-4][Ff][Yy]\d{2}$
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi