Skip to main content
 首页 » 编程设计

python之在 Python 中使用正则表达式从字符串中的源代码中提取字符串常量

2025年05月04日23mq0036

<分区>

如何从字符串中的源代码中获取字符串常量?

例如,这是我要处理的源代码:

var v = "this is string constant + some numbers and \" is also included " 

我无法将所有内容都放在引号内。通过使用此正则表达式:"(.*?)"。

我无法获取 var、v、= 或除字符串字符以外的任何其他内容。