Regex to extract words that contain digits

前端 未结 4 446
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 08:21

I need to extract words that contain digits.

ex:-

Input - 3909B Witmer Road. Niagara Falls. NY 14305

Output - 3909B and 14305

4条回答
  •  囚心锁ツ
    2020-12-19 08:35

    You mean you want to extract number-ey words:

    var matches = Regex.Matches(input, @"\d\w*");
    
    foreach (Match match in matches) {
        var numWord = match.Value;    // 3909B, etc.
    }
    

提交回复
热议问题