Check if a substring exists in a string using Regular Expressions.

By [)ia6l0 iii

Extension method to check if a substring exists in a string using Regular Expressions

public  static string FindMatchInString(this string inputString, Regex re  {
   var match = re.Match(input)String;
   return match.Success ? match.Value : null;
  }

The above code snippet returns the substring that matches in a string based on a Regular Expression

Related FAQs

Extension method to check if an object is null
Extension method to check if a string is null or empty
Extension method to check if a string array contains a particular string
Extension method to check if a substring exists in a string using Regular Expressions
Extension method to check if an object is not null
Check if a substring exists in a string using Regular Expressions.  (1903 Views)