public static string getRegexString(string LengthString,string strRegex, string param) ...{ string s = ""; Regex reg = new Regex(strRegex); Match match = reg.Match(LengthString); if (match.Success) ...{ if (param == "") ...{ s = match.ToString(); } else ...{ s = match.Groups[param].Value.ToString().Trim(); } } return s; }