m 2 Reaktor: use sed-plugin
This commit is contained in:
parent
3a9cbcdcd7
commit
869a278aa8
@ -21,8 +21,8 @@ m = is_regex(line)
|
|||||||
|
|
||||||
if m:
|
if m:
|
||||||
f,t,flagstr = m.groups()
|
f,t,flagstr = m.groups()
|
||||||
f = f.replace('\/','/')
|
fn = f.replace('\/','/')
|
||||||
t = t.replace('\/','/')
|
tn = t.replace('\/','/')
|
||||||
flags = 0
|
flags = 0
|
||||||
count = 1
|
count = 1
|
||||||
if flagstr:
|
if flagstr:
|
||||||
@ -30,10 +30,20 @@ if m:
|
|||||||
flags = re.IGNORECASE
|
flags = re.IGNORECASE
|
||||||
if 'g' in flagstr:
|
if 'g' in flagstr:
|
||||||
count = 0
|
count = 0
|
||||||
|
else:
|
||||||
|
flagstr = ''
|
||||||
last = d.get(environ['_from'],None)
|
last = d.get(environ['_from'],None)
|
||||||
if last:
|
if last:
|
||||||
print(f,t,last)
|
print(fn,tn,last)
|
||||||
print(re.sub(f,t,last,count=count,flags=flags))
|
#print(re.sub(fn,tn,last,count=count,flags=flags))
|
||||||
|
from subprocess import Popen,PIPE
|
||||||
|
p = Popen(['sed','s/{}/{}/{}'.format(f,t,flagstr)],stdin=PIPE,stdout=PIPE )
|
||||||
|
so,_ = p.communicate(last+"\n")
|
||||||
|
if p.returncode:
|
||||||
|
print("something went wrong when trying to process your regex")
|
||||||
|
print(so)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("no last message")
|
print("no last message")
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user