Js 正则表达式到 Python 正则表达式 [英] Js Regex to Python regex

查看:125
本文介绍了Js 正则表达式到 Python 正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个正则表达式 /data-super-full-img\s*=\s*"(.+?)"/im 现在需要将其转换为 Python 正则表达式.我正在尝试做这样的事情 r"data-super-full-img\s*=\s*"(.+?)"im 但在不起作用

I have this regex /data-super-full-img\s*=\s*"(.+?)"/im and now it's needed to be converted into Python regex. I'm trying to do something like this r"data-super-full-img\s*=\s*"(.+?)"im but in doesn't work

推荐答案

您应该删除正则表达式末尾的 im.在 python 中,您可以将标志作为参数传递给您想要的函数.例如:

You should remove the im at the trailing of your regex. In python you can pass the flags as an argument to your intended function. For example:

re.search(r'data-super-full-img\s*=\s*\"(.+?)\"', my_string, flags=re.I|re.M)

这篇关于Js 正则表达式到 Python 正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆