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
|
673 Discussions
|
Please Login in order to post a comment
pattern = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";
String from0to199="[0-1]?\d{1,2}"; String from200to249="2[0-4]?\d"; String from250to255="25[0-5]"; String from0to255 ="(" + from0to199 + "|" + from200to249 + "|" + from250to255 + ")"; String dot="\."; String pattern=from0to255+dot+from0to255+dot+from0to255+dot+from0to255;
Seriously, Is this a Java exercice?!
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