This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 4 years ago.
I have a series of dates that I am trying to separate into years, months and days. These dates are in the yyyy-mm-dd format. I'm not very familiar with RegEx, but I have tried (\dddd)\-(\dd)\-(\dd).
Any help is appreciated.
Accepted answer would also match invalid dates like 1234-56-78, or if mm & dd were in the wrong positions.
([1-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])
Does a little more validation.
Related
This question already has answers here:
Perform calculation only if both cells are not blank with arrayformula? [duplicate]
(3 answers)
ArrayFormula and "AND" Formula in Google Sheets
(4 answers)
Closed 4 months ago.
So I am trying to get this Arrayformula to work so I can plot this formula instead of calculating every Y myself.
=arrayformula(Sum(IF(Z3:Z294>Y$1;IFS(AB3:AB294>0;0;Z3:Z294>Y$1;Y3:Y294-(F3:F294*Y$1));0)-(Sum(IF(and(J3:J294>0;Z3:Z294>Y$1);F3:F294;0)))))
It gives me the (correct) return of this part:
Sum(IF(Z3:Z294>Y$1;IFS(AB3:AB294>0;0;Z3:Z294>Y$1;Y3:Y294-(F3:F294*Y$1));0)
But it doesn't subtract the second part:
-(Sum(IF(and(J3:J294>0;Z3:Z294>Y$1);F3:F294;0)))))
I am quite new to extensive Excel/Sheets formulas so I have no idea how to get this to work, It is also quite weird that the second part doesn't add up even seperate from the first part. So this also doesn't work:
=arrayformula(Sum(IF(and(J3:J294>0;Z3:Z294>Y$1);F3:F294;0)))
I hope it makes some sense without any context, thanks in advance!
Have a great rest of your day,
P.S. Please ignore simple mistakes, I don't code that often in Sheets ;)
AND is not supported. instead of
and(J3:J294>0;Z3:Z294>Y$1)
do this:
(J3:J294>0)*(Z3:Z294>Y$1)
This question already has answers here:
Regex to match Date
(7 answers)
Closed 2 years ago.
I made a google forms which i asked a date of birth like dd/mm/yyyy.
I'm looking for a RegEx that allow every date from 01/01/1900 to 31/12/2015 but refuse every date who contains this 5 years 2016, 2017, 2018, 2019, 2020.
Does someone have an idea ?
Thanks for help.
If you really only want to check dates for years 1900-2015, it suffices to code
\b(\d{1,2}/\d{1,2}/(19\d{2}|200\d|201[0-5]))\b
The \b...\b bound is less restrictive than ^...$
Because the previous answer did not specify any year bounds, they need to be added, for example, 1900…2099 (excluding 2016-2020)
\b(?!2016|2017|2018|2019|2020)(\d{1,2}/\d{1,2}/(19|20)\d{2})\b
This question already has answers here:
Regular expression to count number of commas in a string
(9 answers)
Closed 4 years ago.
I need to check for users that are putting their id in the wrong input box.
They might enter the id as 123-456-789-012 or 123456789012 or some variation so I can't just check for digits. The length of the id varies slightly per user, but is always more than 10 digits.
Valid input is a mix of characters and 0-10 digits.
I've seen a lot of solutions for plain digits, but not mixed text. I tried variations of
(\D*\d){0,10}
but that didn't work.
You want "0-n non-digits" then "1-10 lots of a digit-and-any-non-digits":
^\D*(\d\D*){1,10}$
This question already has answers here:
Regular Expression to describe Credit Card expiry (valid thru) date
(3 answers)
Closed 6 years ago.
I'm trying to find a regex pattern to validate credit card expiration date. The format is MM/YYYY
00/0000 -> Not accepted
02/0000 -> Not accepted
00/2016 -> Not accepted
02/2016 -> accepted
12/2016 -> acceptedenter code here
13/2016 -> Not accepted
the two number of the year must be 20
the year doesn't be under 2016
Any ideas?
thanks
You want this -- not that it's the only solution:
(0[1-9]|10|11|12)/20[0-9]{2}$
PS: This requires the -E tag if being used with grep.
PPS: This answer assumes that the expiration date is at the end of a line.
PPPS: If you want an explanation, give me a ring. :)
This regular expression (posted on here as an answer) is supposed to handle dd/MM/yyyy with leap years included but it doesn't handle day 19 for some reason.
What is needs to be changed to fix this?
(^(((0[1-9]|[12][0-8])[\/](0[1-9]|1[012]))|((29|30|31)[\/](0[13578]|1[02]))|((29|30)[\/](0[4,6,9]|11)))[\/](19|[2-9][0-9])\d\d$)|(^29[\/]02[\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)
Fixed it for you
Changed "[12][0-8]" <-- doesn't include 19 to "1[0-9]|2[0-8]"
"(^(((0[1-9]|1[0-9]|2[0-8])[\/](0[1-9]|1[012]))|((29|30|31)[\/](0[13578]|1[02]))|((29|30)[\/](0[4,6,9]|11)))[\/](19|[2-9][0-9])\d\d$)|(^29[\/]02[\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)"
I found this one validates 2320 and 3000 as non leap years correctly.
^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$