Pages: 1
RSS
how to find IPv4 addresses in the middle of a string
 

I am trying to create two separate regex expressions, the first is  trying to find ipv4 addresses in  the 192.168.0.x range in the middle of  a large string, which also contains large amounts of white-spaces and  other numerals.auto clicker
[P]The second expression is underneath the same conditions, but the address is in the 10.x.x range :

Sample valid addresses: 192.168.0.0 / 192.168.0.255 and 10.0.0.0 / 10.0.255.255

I  have very little experience with regex: my attempt at solving the first  problem was  (192\.168\.0\.)+([0-9]|[1-8][0-9]|9[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])

[P]I  believe that this is on the wrong track, and want to see how it's  properly done, or at least some tips on finding a solution. I am using a  java environment to parse the strings
Edited: Linda Baird - 15 June 2020 02:44:49 (Added more information)
 
Quote
Linda Baird wrote:
I believe that this is on the wrong track, and want to see how it's properly done, or at least some tips on finding a solution.

This is probably not the best place to look for answers. The Bat will let you use regular expressions, but we don't seem to have any resident RegEx experts here. Finding IPs in text files is a very common task though and you shouldn't have much trouble finding the right expressions elsewhere:

https://www.google.com/search?q=find+ipv4+address+regex
I volunteer as a moderator to help keep the forum tidy. I do not work for Ritlabs SRL.
Pages: 1