【问题标题】:regular expression js to python正则表达式js到python
【发布时间】:2012-07-04 16:15:16
【问题描述】:

我打开了 Mozilla Firefox 插件 Wappalizer 并看到了以下 JavaScript。这是正则表达式吗,在python中可以使用吗?

    'CO2Stats':              { cats: { 1: 10 }, html: /src=("|')http:\/\/www\.co2stats\.com\/propres\.php/ },
    'CodeIgniter':           { cats: { 1: 18 }, headers: { 'Set-Cookie': /(exp_last_activity|exp_tracker|ci_session)/ }, implies: [ 'PHP' ] },
    'Commerce Server':       { cats: { 1:  6 }, headers: { 'COMMERCE-SERVER-SOFTWARE': /.+/ } },
    'comScore':              { cats: { 1: 10 }, html: /<i{1}frame[^>]* (id=("|')comscore("|')|scr=[^>]+comscore)/, env: /^_?COMSCORE$/i },
    'Concrete5':             { cats: { 1:  1 }, meta: { 'generator': /concrete5/i } },

【问题讨论】:

  • 当然是js正则表达式,可以用python re翻译一下

标签: javascript python regex firefox-addon


【解决方案1】:

是的,这里// 中的字符串是正则表达式,您可以借助re 模块在python 中使用它们。

import re
if re.match('(exp_last_activity|exp_tracker|ci_session)', header_string):
  # do something

当然,你需要找到你必须用这个表达式分析什么字符串。

【讨论】:

    猜你喜欢
    • 2017-11-13
    • 1970-01-01
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多