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
|
643 Discussions
|
Please Login in order to post a comment
my solution:
class MyRegex{ String pat = "([01]?[0-9]?[0-9]?|2[0-4]?[0-9]|2[0-5]?[0-5?])"; String pattern = "^" + pat + "\." + pat + "\." + pat + "\." + pat ; }
Here pat accepts number string only ranges between 0 to 255. Pattern make sures that IP addr should start with number 0 to 255 and "\." add point between numbers.