How can i fetch 192.168.1.101 usin regex in java in following string ,however Bcast may be or not present
' inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0'
with leading space
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use something like this:
I really feel Abhishek Simon’s answer for the regex is an overkill. You are just extracting, not validating if it is a legal IP address!
For Bcast use something like below, obviously:
To get all IPs, use without the initial lookahead.
You might be better of doing some string operations like splitting on
and:to get the IPs. I leave it to you to decide.