In: Computer Science
Regular Expression to validate Date:YYYY-MM-DD is
([D][a][t][e][:][12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))
Java program used for varify:
public class Main
{
public static void main(String[] args) {
String str="Date:2016-11-15";
System.out.println(str.matches("([D][a][t][e][:][12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))"));
}
}
Varify in java: (Note: In program we use \\d instead of \d because if we use only \d compiler take it as a space character)
Output 1:
Output 2:
Output 3:
Output 4:
Answer 2:
In c << is a left shift operator.
n<<c is equivalent to multiplying n with 2c
Suppose value of c=2 and value of n=4
then it is 4*22 =4*4=16
C program used for varify:
#include <stdio.h>
int main()
{
int n=4;
printf("value of n<<2 is %d",n<<2);
return 0;
}
Output 1: (here value of n is taken 0 by default by compiler)
So it solve like: 0*22=0
Output 2: