Adguard Converter : Support some others regex

This commit is contained in:
Minoplhy 2021-12-12 17:20:24 +07:00
parent 1ead434734
commit 0aa0c982fa
Signed by: minoplhy
GPG Key ID: 90667A59A9908AEC
2 changed files with 22 additions and 4 deletions

View File

@ -6,7 +6,16 @@ from shutil import copyfile
infile = sys.argv[1]
outfile = sys.argv[2]
a = ['||','^']
with open(infile) as f:
file = f.read().split('\n')
for i in range(len(file)):
file[i] = re.sub('(..*#..*)|(@@\|\|..*)|(\|\|..*\/..*)|(^\/..*)|(^..*\$app=..*)|(^..*\$removeparam=..*)|(^..\/..*)|(\$..*)|(^\...*)|(^:..*)|(^\|http)|(^@@..*)|(^_..*)|(\*..*)', '', file[i])
#print(file)
with open(infile, 'w') as f1:
f1.writelines(["%s\n" % item for item in file])
f.close()
a = ['||','^','|']
lst = []
with open(infile, 'r') as f:

View File

@ -1,11 +1,20 @@
import os
import sys
from re import sub
import re
from shutil import copyfile
infile = sys.argv[1]
outfile = sys.argv[2]
with open(infile) as f:
file = f.read().split('\n')
for i in range(len(file)):
file[i] = re.sub('(..*#..*)|(@@\|\|..*)|(\|\|..*\/..*)|(^\/..*)|(^..*\$app=..*)|(^..*\$removeparam=..*)|(^..\/..*)|(\$..*)|(^\...*)|(^:..*)|(^\|http)|(^@@..*)|(^_..*)|(\*..*)', '', file[i])
#print(file)
with open(infile, 'w') as f1:
f1.writelines(["%s\n" % item for item in file])
f.close()
a = ['||','^','|']
lst = []
@ -24,7 +33,7 @@ f.close()
with open(infile) as f:
file = f.read().split('\n')
for i in range(len(file)):
file[i] = sub(r'!', ';', file[i])
file[i] = re.sub(r'!', ';', file[i])
#print(file)
with open(infile, 'w') as f1:
f1.writelines(["%s\n" % item for item in file])
@ -48,7 +57,7 @@ f.close()
with open(infile) as f:
file = f.read().split('\n')
for i in range(len(file)):
file[i] = sub('^@@', '', file[i])
file[i] = re.sub('^@@', '', file[i])
#print(file)
with open(infile, 'w') as f1:
f1.writelines(["%s\n" % item for item in file])