#coding=utf-8
 
__author__ = 'WangHai zhen'

import os
import re

def clear(fp):
    if re.search('\[',fp):
        if fp.find(']') != -1:
            fp = fp.replace("[","l").replace("]","l")
            pattern = re.compile(r'(l)(.+)(l)')
            return pattern.sub(r'',fp)
        else:
            return fp
    elif re.search(u'【',fp):
        if fp.find(u'】') != -1:
            fp = fp.replace(u"【","l").replace(u"】","l")
            pattern = re.compile(r'(l)(.+)(l)')
            return pattern.sub(r'',fp)
        else:
            return fp
    elif re.search('\-',fp):
        return fp.replace(u"-","")
    else:
        return fp


path = 'E:\\Workspace\\markdown.md\\py-tree\\x_x\\example_input'
for i in os.listdir(os.getcwd()):
    if i == "x_x.py":
        continue
    t = (clear(i)).split('.')
    while '' in t:
        t.remove('')
    newname = '.'.join(t)
    os.rename(os.path.join(path,i),os.path.join(path,newname)) #对文件进行重命名     #对原来的文件名i进行重命名
    #print(i)       #输出当前目录下重命名后的文件名

@@ -95,36 +95,28 @@
 rch('%5C%5B',fp)
-:%0A        if
+ and
  fp.find('%5D'
@@ -136,176 +136,75 @@
     
-    fp = fp.replace(%22%5B%22,%22l%22).replace(%22%5D%22,%22l%22)%0A            patte
+retu
 rn
- =
  re.
-compile(r'(l)(.+)(l)')%0A            return pattern.sub(r
+sub('%5C%5B.*?%5C%5D', 
 '',
+ 
 fp)
-%0A        else:%0A            return fp
+  #re.sub()%E5%B0%86fp%E4%B8%AD%E5%8C%B9%E9%85%8D'%5C%5B.*?%5C%5D'%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%9B%BF%E6%8D%A2%E4%B8%BA''
 %0A   
@@ -231,20 +231,12 @@
 ,fp)
-:%0A        if
+ and
  fp.
@@ -265,178 +265,73 @@
     
-    fp = fp.replace(u%22%E3%80%90%22,%22l%22).replace(u%22%E3%80%91%22,%22l%22)%0A            patte
+retu
 rn
- =
  re.
-compile(r'(l)(.+)(l)')%0A            return pattern.sub(r
+sub('%5C%E3%80%90.*?%5C%E3%80%91', 
 '',
+ 
 fp)
-%0A        else:%0A            return fp
+#re.sub()%E5%B0%86fp%E4%B8%AD%E5%8C%B9%E9%85%8D'%5C%E3%80%90.*?%5C%E3%80%91'%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%9B%BF%E6%8D%A2%E4%B8%BA''
 %0A   
@@ -419,16 +419,21 @@
 turn fp%0A
+     
 %0A%0Apath =
@@ -437,13 +437,13 @@
 h = 
+r
 'E:%5C
-%5C
 Work
@@ -448,17 +448,16 @@
 rkspace%5C
-%5C
 markdown
@@ -464,17 +464,16 @@
 .md%5C
-%5C
 py-tree%5C
 %5Cx_x
@@ -472,14 +472,12 @@
 ree%5C
-%5C
 x_x%5C
-%5C
 exam
@@ -560,16 +560,39 @@
 ontinue%0A
+    #print(clear(i))%0A %0A
     t = 

optimize x_x.py