im trying regex expression can plugin find strings in file. example if had file had
using system; public class test: testclass{ public int val1 = 0; public string val2 = "value"; //this "test" class public test(value = "temp"){ val2 = value; } }
id want expression return ["value", "temp"]
here python file im using now.
import os import shutil import subprocess import codecs import sys import re pattern = re.compile("((?:[^\"\\\\]|\\\\.)*)") codecs.open(filepath,"r","utf-8") f: line in f.readlines(): m = re.findall(pattern, line) string in m: print string
apply re.findall
function on lines won't startswith //
.
with codecs.open(filepath,"r","utf-8") f: out = [] line in f: if not line.strip().startswith('//'): out.extend(re.findall(r'"([^"]*)"', line)) print out
Comments
Post a Comment