Skip to content

Instantly share code, notes, and snippets.

@bkeating bkeating/rejjjex.py
Created Nov 19, 2015

Embed
What would you like to do?
"""
Examples:
update_option( "foobar" )
update_option( 'your_mom_lol' )
update_option("another_func")
update_option('some_long_name')
Regex:
update_option\(\s*('|")(.*)('|")\s*\)
"""
import fnmatch
import os
import re
# Recursively walk the plugins folder and build a lits of PHP files
file_list = []
for root, dirnames, filenames in os.walk('wp_plugins'):
for filename in fnmatch.filter(filenames, '*.php'):
file_list.append(os.path.join(root, filename))
# Search each file for matching regex pattern
regex = re.compile('update_option\(\s*\'|"(.*)\'|"')
for filename in file_list:
with open(filename) as fobj:
output = re.search(regex, fobj.read())
if output:
print filename
print output.group()
print "=============================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.