title: How to check private/local IP address by using regular expression
body: <p>Hope all of you will be fine. I am building an IOS application in which I warn the user if they typed a private/local IP address in text-field.
  I have searched on internet and found it done in the Android app using regular expression:
  Java: (127.0.0.1)|(192.168.$) | (172.1[6-9].$) | (172.2[0-9].$) | (172.3[0-1].$) | (10.*$)</p>
  
  <p>I want the same regular expression for IOS application but I don't know how to code it.
  I searched on internet and found 
  <a href="https://stackoverflow.com/questions/2814002/private-ip-address-identifier-in-regular-expression">Private IP Address Identifier in Regular Expression</a>
  but i could not understand it. I just know some objective-c. Can some one help me in this regard please.</p>
  
  <p>Ok guys finally I think I have solved the problem by following code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>-(void)CheckIP
  {
      NSError *error = NULL;
      NSString *pattern = @"(127.0.0.1)|(192.168.$)|(172.1[6-9].$)|(172.2[0-9].$)|(172.3[0-1].$)|(10.*$)";     // "[a-zA-Z]+[,]\\s*([A-Z]{2})";
      NSString *string = self.tfExternalHost.text;
      NSRange range = NSMakeRange(0, string.length);
      NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&amp;error];
      NSArray *matches = [regex matchesInString:string options:NSMatchingProgress range:range];
      NSLog(@" Found Match %@", matches);
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Suggest me if the above code can be improved.</p>