We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Strings
- Java Regex
- Discussions
Java Regex
Java Regex
Sort by
recency
|
670 Discussions
|
Please Login in order to post a comment
finally I did it Because of Zeros at the beginig i waste so much time. import java.io.; import java.util.; import java.util.regex.*;
public class Solution {
}
class MyRegex { public String strPatern = "^(0{0,2}[0-9]|0[0-9]{2}|[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." + "(0{0,2}[0-9]|0[0-9]{2}|[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." + "(0{0,2}[0-9]|0[0-9]{2}|[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\." + "(0{0,2}[0-9]|0[0-9]{2}|[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
}
This is a great exercise for understanding how to construct complex regular expressions! cricketbuzz mahadev
here is my code without regex in java
import java.io.; import java.util.;
public class Solution {
String input = reader.readLine(); while (input != null){ System.out.println(MyRegex.checkIP (input)); input = reader.readLine(); } }
}
class MyRegex { public static boolean checkIP (String input) { int startNum = 0 ; for (int i=1 ; i < 5 ; i++){ int currentDot = input.indexOf(".", startNum);
} return true; }
}