title: Regular expression to check for integer or decimal number in iOS
body: <p>I need to check whether the text is an integer or a decimal number.</p>
  
  <p>I tried using the following: </p>
  
  <pre><code>NSString *expression =  @"\\d*";         
  NSError *error ;
  NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:expression options:NSRegularExpressionCaseInsensitive error:&amp;error];
  NSTextCheckingResult *isValid = [regex firstMatchInString:txt options:0 range:NSMakeRange(0, [txt length])];
  </code></pre>
  
  <p>But the result is true even if the text is <code>2.14.256</code>.</p>