小编And*_*pez的帖子

Python - 正则表达式获取括号之间的数字

当我的值在单词“PIC”和“.”之间时,我需要帮助创建一个正则表达式来获取括号之间的数字。

我得到了这个记录,需要能够在 () 之间提取值

PIC S9(02)V9(05).    I need this result "02 05"
PIC S9(04).          I need this result "04"
PIC S9(03).          I need this result "03"
PIC S9(03)V9(03).    I need this result "03 03" 
PIC S9(02)V9(03).    I need this result "02 03"
PIC S9(04).          I need this result "04"  
PIC S9(13)V9(03).    I need this result "13 03"
Run Code Online (Sandbox Code Playgroud)

我尝试了以下但它不起作用。

s = "PIC S9(02)V9(05)."
m = re.search(r"\([0-9]+([0-9]))\", s)
print m.group(1)
Run Code Online (Sandbox Code Playgroud)

python regex numbers brackets between

2
推荐指数
1
解决办法
7878
查看次数

标签 统计

between ×1

brackets ×1

numbers ×1

python ×1

regex ×1