Extract number at end of string in C#

前端 未结 9 2427
無奈伤痛
無奈伤痛 2020-12-17 08:03

Probably over analysing this a little bit but how would stackoverflow suggest is the best way to return an integer that is contained at the end of a string.

Thus far

9条回答
  •  青春惊慌失措
    2020-12-17 09:02

    Is it always in the format LettersNumbers?

    In that case, this would work:

    Regex _cellAddressRegex = new Regex(@"(?[a-z]+)(?[0-9]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    var rowm = Convert.ToInt32(parts.Groups["Row"]);
    

提交回复
热议问题