2021年1月4日星期一

Regular Expression how to match IP and port after a few garbage data

I'm trying to extract the IP and Port from html text.

The data looks like this

177.93.79.34\n<!--\n<img src='images/proxy/3537536.gif' border='0' hspace='0' vspace='0' width='140' height='14' alt='View this Proxy details'/>\n-->\n</a></td>\n\t<td><a href='/proxy-4145-Socks4--ssl.htm' title='Select proxies with port number 4145'>4145


My regular expression pattern looks like this.

MatchCollection Match = Regex.Matches(source, @"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b\s\S.*Select proxies with port number ([0-9]+)");

I also try this \b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b[\s\S].*Select proxies with port number ([0-9]+)

But I get 0 results.. if I take off \b\s\S.*Select proxies with port number ([0-9]+) it finds all the IP addressses great.. but the information is useless without the port data how would I both in 1 regular expression match.

https://stackoverflow.com/questions/65572438/regular-expression-how-to-match-ip-and-port-after-a-few-garbage-data January 05, 2021 at 10:33AM

没有评论:

发表评论