In [46]:
import re
def dashrepl(matchobj):
    if matchobj.group(0) == '[':
        return ''
    if matchobj.group(1) == ']':
        return ''


re.sub(r'(?\[{1}))', dashrepl, '["hola","lolo"]')

#re.sub(r'\sAND\s', ' & ', 'Baked Beans And Spam', flags=re.IGNORECASE)


---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-46-d263c9eba0a5> in <module>()
      7 
      8 
----> 9 re.sub(r'(?\[{1}))', dashrepl, '["hola","lolo"]')
     10 
     11 #re.sub(r'\sAND\s', ' & ', 'Baked Beans And Spam', flags=re.IGNORECASE)

/home/leudis/anaconda2/lib/python2.7/re.pyc in sub(pattern, repl, string, count, flags)
    153     a callable, it's passed the match object and must return
    154     a replacement string to be used."""
--> 155     return _compile(pattern, flags).sub(repl, string, count)
    156 
    157 def subn(pattern, repl, string, count=0, flags=0):

/home/leudis/anaconda2/lib/python2.7/re.pyc in _compile(*key)
    249         p = sre_compile.compile(pattern, flags)
    250     except error, v:
--> 251         raise error, v # invalid expression
    252     if not bypass_cache:
    253         if len(_cache) >= _MAXCACHE:

error: unexpected end of pattern

In [ ]:


In [ ]:


In [ ]: