Branch Reset Groups

Sort by

recency

|

92 Discussions

|

  • + 0 comments

    Java 15

    import java.io.*;
    import java.util.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    public class Solution {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in); //(---)|-|.|:
            Pattern pattern = Pattern.compile("^\\d{2}(---|-|\\.|:)(\\d{2}\\1){2}\\d{2}$");
            Matcher matcher = pattern.matcher(scanner.nextLine());
            System.out.println(matcher.find());
        }
    }
    
  • + 0 comments

    \1 reference the group

    import java.io.*;
    import java.util.*;
    import java.util.regex.Pattern ;
    import java.util.regex.Matcher ;
    public class Solution {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in) ;
            String s = in.nextLine() ;
            String pattern = "^[0-9]{2}(-|:|---|\\.){1}[0-9]{2}\\1[0-9]{2}\\1[0-9]{2}$"  ;
            Pattern pat  = Pattern.compile(pattern) ;
            Matcher matcher = pat.matcher(s) ;
            boolean match = matcher.find() ;
            if(match)
            {
                System.out.println("true") ;
            }
            else
            {
                System.out.println("false") ;
            }  
        }
    }
    
  • + 0 comments

    JAVA

    \d{2}(---|-|\.|:)(\d{2}\1?){3}

  • + 0 comments

    tS

    function main() {
        // Enter your code here
        let regexPattern: RegExp = /^\d\d(-|---|,|\.|:)(\d\d\1?){3}$/;
        let testString:string = readLine();
        console.log(!!testString.match(regexPattern))
    }
    
  • + 0 comments

    java

    "^\\d{2}(-|.|---|:)?\\d{2}\\1\\d{2}\\1\\d{2}$"