Skip to content

Commit

Permalink
Create JavaRegex.java
Browse files Browse the repository at this point in the history
  • Loading branch information
debeshp6 authored Jan 26, 2024
1 parent fbf1c9f commit 9555b9a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions JavaRegex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Scanner;

class Solution{

public static void main(String[] args){
Scanner in = new Scanner(System.in);
while(in.hasNext()){
String IP = in.next();
System.out.println(IP.matches(new MyRegex().pattern));
}

}
}

//Write your code here
class MyRegex {
String num = "([01]?\\d{1,2}|2[0-4]\\d|25[0-5])";
String pattern = num + "." + num + "." + num + "." + num;
}

0 comments on commit 9555b9a

Please sign in to comment.