I need to get a particular id from the quotes.
Input string is below
thecodeis = "3468337910";
expecting the output to be below
3468337910
I tried with couple of options but the closest I got was .*
I need to get a particular id from the quotes.
Input string is below
thecodeis = "3468337910";
expecting the output to be below
3468337910
I tried with couple of options but the closest I got was .*
在蟒蛇:
string = 'thecodeis = "34688337910";'
pattern = 'thecodeis\s*=\s*"([0-9]+)";'
re.findall(pattern, string) // return ['34688337910']
如果您的输入字符串具有不同的格式,请pattern
改用:
pattern = '"([0-9])+"'
它将返回页面中引号之间的所有数字。
你的正则表达式很接近
".*"
但是,如果您只想要数字,则应将其捕获在带括号的组中
"(.*)"
您使用什么语言?也许我们可以帮助语法
使用\d+
- 它将捕获字符串中的至少一位数字。
您应该能够使用 "([\d])" 因为这将在字符串中找到任何数字。
如果您可以提供更多详细信息,例如您尝试在哪种语言中执行此操作,或者它是否适用于 .htaccess 文件,那么您应该得到更具体的回复。
用这个
"([^"]+?)"
解释
<!--
"([^"]+?)"
Options: case insensitive
Match the character “"” literally «"»
Match the regular expression below and capture its match into backreference number 1 «([^"]+?)»
Match any character that is NOT a “"” «[^"]+?»
Between one and unlimited times, as few times as possible, expanding as needed (lazy) «+?»
Match the character “"” literally «"»
-->