Regular expression for printing integers within brackets

前端 未结 3 1529
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 18:35

First time ever using regular expressions and can\'t get it working although there\'s quite a few examples in stackoverflow already.

How can I extract integers which are

3条回答
  •  [愿得一人]
    2021-01-21 19:14

    If you want to extract integers from a string the code that I use is this:

    def stringToNumber(inputStr):
    myNumberList = []
    for s in inputStr.split():
        newString = ''.join(i for i in s if i.isdigit())
        if (len(newString) != 0):
            myNumberList.append(newString)
    return myNumberList
    

    I hope it works for you.

提交回复
热议问题