if it's possible to do for exemple +1 -1 for to check the date ?
Not quite understand this, are you trying to do a math in your regular expression? Based on current year and get the last&next year? In this case you should get three years 18, 19 and 20 rather than just 19 and 20.
jimmy69
I would like just to accept two digits and these two digit can be only 19 OR 20
If you just want 19 or 20, just use the basic | in
regular expression like @mgebhard told.
Contributor
2195 Points
950 Posts
Regex -> Barre code pattern
Dec 05, 2019 03:40 PM|jimmy69|LINK
Hello all,
we have an application who used an regex as this one :
^(?[1][1-9])(?[A|X|Y|Z]\w)(?\d{6})(?
[3])(?\d{4})$
this regex check a format of a barre code.
It's work fine UNTIL the end of this year because we check the date in the begining of the regex -> [1][1-9]
Ok, I can modify the regex for to accept the next year as this -> [1-2][0-9]
this change will accept the barre code begin by 19xxxxx OR 20xxxx OR 10xxxxx
but i'm not really satisfied by this change because my regex MUST TO check the date 19 OR 20
Someone can tell me, if it's possible to do for exemple +1 -1 for to check the date ?
ex : I would like just to accept two digits and these two digit can be only 19 OR 20
thanks for all
All-Star
52961 Points
23563 Posts
Re: Regex -> Barre code pattern
Dec 05, 2019 04:04 PM|mgebhard|LINK
The RegEx shown has syntax errors. Why cant you use a basic OR like you are already using?
Contributor
3140 Points
983 Posts
Re: Regex -> Barre code pattern
Dec 06, 2019 05:39 AM|Yang Shen|LINK
Hi jimmy69,
Not quite understand this, are you trying to do a math in your regular expression? Based on current year and get the last&next year? In this case you should get three years 18, 19 and 20 rather than just 19 and 20.
If you just want 19 or 20, just use the basic | in regular expression like @mgebhard told.
Best Regard,
Yang Shen
Contributor
2195 Points
950 Posts
Re: Regex -> Barre code pattern
Dec 06, 2019 09:01 AM|jimmy69|LINK
Hello all,
thanks for your time .
@mgebhard -> yes I can use 19|20 but next year I need to change to 20|21
@yang Shen -> yes I would like to make some math if POSSIBLE .. make something like +1 -1 ?
I would like something like accept 19 20 21 22 perhpas the best solution will be to make an OR ?
thanks for all
Contributor
3140 Points
983 Posts
Re: Regex -> Barre code pattern
Dec 06, 2019 09:34 AM|Yang Shen|LINK
Hi jimmy69,
I don't think the regex can do calculation, but it's easy to be done in js or any other code language depends where would you use this regex.
For example, you can see i did the dynamic regex in JS in below demo:
Below is the result of this demo:
Best Regard,
Yang Shen
Contributor
2195 Points
950 Posts
Re: Regex -> Barre code pattern
Dec 09, 2019 08:17 AM|jimmy69|LINK
Hello all,
thanks for your time you spend here ..
great to find any help and advice