I would like to check if the strings respect the following date format: dd/mm/YYYY
If the day or the month is unknown, we admit to replace it by nk (upper or lower case).
So, the accepted strings in our example are: "na-05-2021", and "NK-nk-1965".
The other are not accepted.
I did the following regex but the returned results are not what i expected:
#install.packages("stringr")
library(stringr)
result <- str_detect(string_test , "/^(nk|NK|(0[1-9]|[12]/d|3[01]))+(-)+(nk|NK|0[1-9]|1[0-2])(-)+(1|2)+(0|9)+[0-9]+[0-9]/", negate = TRUE)
I think it's a problem with the regex but i tested it in https://regexr.com/ and it works as expected.
You are right but where can I find a website to test my regex in ICU flavor because I didn't find anything and also, I don't understand why it doesn't give me an error but an incorrect result.
It test if the string match with a correct date format dd-mm-yyyy and if day or month is unknown, "nk" (upper or lower case) is admitted. (e.g.: nk-01-2021, nk-nk-2021, etc.)