Regex : Find a number between parentheses

后端 未结 2 1866
执笔经年
执笔经年 2020-12-25 13:37

I need a regex who find the number in bold below :

20 (L.B.D.D. hello 312312) Potato 1651 (98)

20 (L.B.D.D. hello 312312 bu

2条回答
  •  星月不相逢
    2020-12-25 14:14

    This only matches 312312 in the first capture group:

    ^.*?\([^\d]*(\d+)[^\d]*\).*$
    

    Regexplanation:

    ^        # Match the start of the line
    .*?      # Non-greedy match anything
    \(       # Upto the first opening bracket (escaped)
    [^\d]*   # Match anything not a digit (zero or more)
    (\d+)    # Match a digit string (one or more)
    [^\d]*   # Match anything not a digit (zero or more)
    \)       # Match closing bracket
    .*       # Match the rest of the line
    $        # Match the end of the line
    

    See it here.

提交回复
热议问题