Check If a String Contains IPv4 Address in VB.Net -
how can tell if string contains ipv4 address. want ip addresses in string.
exemple:
the following string contains 4 ipv4 addresses:
2016-01-16 00:00 - [99.245.14.88] downloaded ... 2016-01-16 00:00 - [120.103.139.95] downloaded ... 2016-01-15 23:59 - [166.118.4.233] downloaded ... 2016-01-15 23:59 - [55.234.129.191] downloaded ...
here code made each ip..
dim regex new system.text.regularexpressions.regex("\[(([\d]{1,3}\.?){4})\]", system.text.regularexpressions.regexoptions.multiline) dim matches system.text.regularexpressions.matchcollection = regex.matches(textbox1.text) 'replace textbox string source dim tmp string = "" each match system.text.regularexpressions.match in matches 'do each ip : match.groups(1).value tmp &= match.groups(1).value & vbnewline next msgbox(tmp)
it uses regular expression, if going work text lot should read how work. if looking don't forget mark answer , upvote.
Comments
Post a Comment