badc0re
badc0re

Reputation: 3523

regular expression js to python

I opened the Mozilla Firefox add-on Wappalizer and saw the following JavaScript. Is this a regular expression, and is it possible to use it in 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 } },

Upvotes: 1

Views: 371

Answers (1)

Igor Chubin
Igor Chubin

Reputation: 64563

Yes, the strings that are in // here are regular expression and you can use them in python with help of the re module.

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

But you need to find what string you must analyze with this expressions, of course.

Upvotes: 1

Related Questions