I have the following string:
22/04/2020 14:10 by [email protected]
And I wrote the following regex:
^(\d{2,4}\/?)+
Why does group 1 only match the last part of the date and not the whole date, and how can I fix this?
I have the following string:
22/04/2020 14:10 by [email protected]
And I wrote the following regex:
^(\d{2,4}\/?)+
Why does group 1 only match the last part of the date and not the whole date, and how can I fix this?
Note that regex store all matches in the array - firstly check in your code all matches. I think that the data that you need - already matched - you just need to store it. Following the Regex101 - Full match - will be your arr[0]. If you are using PHP - check this regex-tester = https://www.phpliveregex.com/
My regex :
^(\d+\W)*
^\d{2}/\d{2}/\d{4}
^((?:\d{2,4}\/?)+)
^(?:\d{2,4}\/?)+
and it could possibly also match a/
at the end