Regex Date

Hello all,

I would need to get the date, but I am not able to find the correct Regex code. Could you help me please?

This is the sentence and I need to get “25/11/20”.

“FECHA 25/11/20”

This is what I tried: (?<=FECHA\s+)[\d,]+

But i just get “25”.

Many thanks :slight_smile:

Angel

@Angel_Llull
To match a date in mm/dd/yyyy format, rearrange the regular expression to
^(0[1-9]|1[012])- /.- /.\d\d$.
For dd-mm-yyyy format, use ^(0[1-9]|[12][0-9]|3[01])- /.- /.\d\d$.

@Angel_Llull,

Try with this regex,

\d?[\/|\-|\s]?\d?[\/|\-|\s]\d(\s?)[\/|\-|\s]?\d?(\s?)[\/|\-|\s]\d{2,4}[\s]?$

@Angel_Llullregexx.zip (14.3 KB) Take this xaml for your reference .

Happy learning:)

Hello @Angel_Llull

(?<=FECHA\s)([0-2][0-9]|(3)[0-1])(/)(((0)[0-9])|((1)[0-2]))(/)\d{2}$

1 Like

Hello @Akshay07,

i am trying this in website RegExr and it gets the date. But in Studio, the variable is empty.

Do you know why is it happening?

Thanks :slight_smile:

Hello @sarathi125,

Thanks! But I am trying it and the variable is empty… Do you know why would it be happening?

Many thanks :slight_smile:

Hello!

Sorry because I did not write whole text because I thought that maybe it was not necessary. But this is the whole sentence:

011A11 00000000 FECHA 25/11/20 CALLE

Would the code change in this case?

Sorry for the inconveniences.

Thanks!

Angel

@Angel_Llull
have a look here:
grafik

(?<=FECHA )(\d+\/?){3}
3 Likes

Thanks! It worked :slight_smile:

Hey

If you want to learn Regex - check out my Regex Megapost.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.