Regex to match an IP address [closed]

Don’t use a regex when you don’t need to 🙂 $valid = filter_var($string, FILTER_VALIDATE_IP); Though if you really do want a regex… $valid = preg_match(‘/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/’, $string); The regex however will only validate the format, the max for any octet is the max for an unsigned byte, or 255. This is why IPv6 is necessary – … Read more

Extract ip addresses from Strings using regex

Richard’s link helped me find the answer. here’s the working code : String IPADDRESS_PATTERN = “(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)”; Pattern pattern = Pattern.compile(IPADDRESS_PATTERN); Matcher matcher = pattern.matcher(ipString); if (matcher.find()) { return matcher.group(); } else{ return “0.0.0.0”; }

Restricting IP addresses for Jetty and Solr

Solr 4.2.1 uses Jetty 8.1.8. Jetty 8 (as noted by jonas789) doesn’t support .htaccess. Instead, it uses IPAccessHandler, which doesn’t have great documentation available. I had to play with it quite a bit to get it work, so I’m posting an updated solution here. IPAccessHandler manages a blacklist and a whitelist, accepts arbitrary ranges of … Read more

Delphi, How to get all local IPs?

in indy 9, there is a unit IdStack, with the class TIdStack fStack := TIdStack.CreateStack; try edit.caption := fStack.LocalAddress; //the first address i believe ComboBox1.Items.Assign(fStack.LocalAddresses); //all the address’ finally freeandnil(fStack); end; works great 🙂 from Remy Lebeau’s Comment The same exists in Indy 10, but the code is a little different: TIdStack.IncUsage; try GStack.AddLocalAddressesToList(ComboBox1.Items); Edit.Caption … Read more

How to use an HTTP proxy in java

You can use the java system properties to set up a proxy or pass it as command line options. You can find some details and samples here. Ex: Before opening the connection System.setProperty(“http.proxyHost”, “myProxyServer.com”); System.setProperty(“http.proxyPort”, “80”); Or you can use the default network proxies configured in the sytem System.setProperty(“java.net.useSystemProxies”, “true”); Since Java 1.5 you can … Read more