gpt4 book ai didi

regex - 正则表达式:在括号之间找到一个数字

转载 作者:行者123 更新时间:2023-12-03 21:01:41 28 4
gpt4 key购买 nike

我需要一个正则表达式,它会在下面以粗体显示该数字:

20(L.B.D.D. hello 312312 )土 bean 1651(98)

20(L.B.D.D.你好 312312 兔子)土 bean 1651(98)

20( 312312 )土 bean 1651(98)

[[\ d +))找到数字98

当括号中还有其他字符时,我不知道该怎么办

最佳答案

这仅与第一个捕获组中的 312312 匹配:

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

解释:
^        # 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

看到它 here

关于regex - 正则表达式:在括号之间找到一个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13807207/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com