[Solved] Python and regex to remove parenthesis in a file [duplicate]


Since you’re calling the script as follows:

python removeparenthesis.py filename.xml

the XML file name will appear under sys.argv[1].

Also, you’d need to use lazy matching in your pattern:

r'\(\w*?\)'    # notice the ?

A better pattern would be:

r'\([^)]*\)'

2

solved Python and regex to remove parenthesis in a file [duplicate]