Regex to extract words that contain digits

前端 未结 4 467
被撕碎了的回忆
被撕碎了的回忆 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:31

    This is the simplest regex I could come up with that can handle words that have a mixture of letters and digits:

    (\w*\d[\w\d]+)
    

    So this will match your desired words, plus it would match 'abc123xyz'. Try it yourself.

提交回复
热议问题