vendredi 10 avril 2020

I need regex to validate a pattern

I need regex to validate a pattern, pattern can be combination of following list,

yyyy : current year

yy : last 2 digits of current year

MM : current month

dd : current day

HH : current hour

mm : current minute

ss : current second

fff : current milisecond

ff : current 1/100th of second

R : random digits

Rules:

Minimum 16 and maximum 20 characters can be allowed.

We should be able to add fix characters only in capitals(e.g. 'yyyyAAddmmss' here AA is fix value)

We should escape a fix character(e.g. \R, then R is not replaced)

only HMR characters should be allowed to escape like '\H' or '\M' or '\R' as this characters are in the pattern.

Pattern should contains minimum 4 random digits (e.g. yyRMMRddRHHRmmRss)

It should allow digits 0-9

It should not allow special characters.

Example of such valid pattern:

yyyyMMddHHmmssff

yyyyMMddHHmmssffR

AByyyyMMddHHmmssRRRR

AByyyy\RMMddHHRRmmRR

\Myy\HMMdd\RRHHmmss99RR

Aucun commentaire:

Enregistrer un commentaire