public static Expense ParseExpenseMessage(string str, Telegram.Bot.Types.User user, ExpenseCategoryRepository expCat) { var inputWithoutSpaces = Regex.Replace(str, @"^\-\s+", ""); inputWithoutSpaces = inputWithoutSpaces.Replace(".", ","); var digitInputValue = Regex.Match(inputWithoutSpaces, @"[0-9]+(\,[0-9]+)?").Value; inputWithoutSpaces = inputWithoutSpaces.Replace(digitInputValue, ""); inputWithoutSpaces = inputWithoutSpaces.Replace(@"-", ""); var category = Regex.Match(inputWithoutSpaces, @"\D+").Value; var money = (float)Convert.ToDouble(digitInputValue, CultureInfo.CurrentCulture); var foundedCategory = expCat.GetByString(category); return(new Expense() { Amount = money, CreatedTime = DateTime.Now, CategoryId = foundedCategory.Id, Id = Guid.NewGuid().GetHashCode(), UserId = user.Id, Definition = category }); }