1

Topic: Again a question on

Kind all day.
Learning of the regular expressions (on js) moves ahead. And it is necessary to pass or abuse time.
I try here so:
((\d {0,2}) sad \d {0,2}) sad \d {0,2})) | (\d {0,2}) sad \d {0,2}) | (\d {0,2}) neutral (\d {0,2}) $
It is necessary to "adjust" time expressions, but it is not absolutely stupid ::, and to pass also such variations:
0:00:00 AM - it is good
00:00 - it is good
00 - it is good
Various that more low as should be passed as well.
:: - it is good
0:0: - it is good
0: - it is good
:: 0 - it is good
And now that I can not understand as to make. I can not strictly specify that between ":" can stand only from 0 to 2 digits if it is more it is necessary to abuse.
Example:
0:00:00 AM - it is bad
000 - it is bad
0:01:01 AM - it is bad
...
Etc.

2

Re: Again a question on

andron81 wrote:

it is necessary to "adjust" time expressions, but it is not absolutely stupid ::, and to pass also such variations:
0:00:00 AM - it is good
00:00 - it is good
00 - it is good
Various that more low as should be passed as well.
:: - it is good
0:0: - it is good
0: - it is good
:: 0 - it is good
And now that I can not understand as to make. I can not strictly specify that between ":" can stand only from 0 to 2 digits if it is more it is necessary to abuse.
Example:
0:00:00 AM - it is bad
000 - it is bad
0:01:01 AM - it is bad
...
Etc.

About "etc." it is not absolutely clear... smile))
And in the enumerated cases, as a variant...

var a = [
' 0:00:00 AM ';
' 00:00 ';
' 00 ';
':: ';
' 0:0: ';
' 0: ';
':: 0 ';
' 0:00:00 AM ';
' 000 ';
' 0:01:01 AM'
];
var re = / ^ (\d\d?)? (:\d? \d?)? (:\d? \d?)? $/;
for (var i=0; i <a.length; i ++) {
alert (a [i] + ' - ' +re.test (a [i]));
};

3

Re: Again a question on

Or so...

var a = [
' 0:00:00 AM ';
' 00:00 ';
' 00 ';
':: ';
' 0:0: ';
' 0: ';
':: 0 ';
' 0:00:00 AM ';
' 000 ';
' 0:01:01 AM'
];
var re = / ^\d? \d? (:\d? \d?)? (:\d? \d?)? $/;
for (var i=0; i <a.length; i ++) {
alert (a [i] + ' - ' +re.test (a [i]));
};

4

Re: Again a question on

Still I will truncate...

var a = [
' 0:00:00 AM ';
' 00:00 ';
' 00 ';
':: ';
' 0:0: ';
' 0: ';
':: 0 ';
' 0:00:00 AM ';
' 000 ';
' 0:01:01 AM'
];
var re = / ^\d? \d? (:\d? \d?) {0,2} $/;
for (var i=0; i <a.length; i ++) {
alert (a [i] + ' - ' +re.test (a [i]));
};

5

Re: Again a question on

krvsa wrote:

About "etc." it is not absolutely clear... smile))

Meant that numbers in line should contain digits in an amount from 0 to 2. No more. Three and above  should reject
Simply it would not be desirable to enumerate all of them.

6

Re: Again a question on

krvsa;
Similar that that is necessary. You the maestro! Thanks