我需要一个正则表达式,在下面找到以粗体显示的数字:
20(LBDD你好312312)马铃薯1651(98)
20(LBDD你好312312兔子)马铃薯1651(98)
20(312312)马铃薯1651(98)
((\ d +))找到数字98
当括号中有其他字符时,我不知道该怎么办
Chr*_*our 51
这仅匹配第一个捕获组中的312312:
^.*?\([^\d]*(\d+)[^\d]*\).*$
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
在这里看到它.