How to replace only pair parentheses by nothing in this expression? I tried many ways, but then I decided to post my question here...
Code:
expression = ')([()])('
pattern = r'[(\(.*\)]'
nothing = ''
print(re.sub(pattern, nothing, expression)) # Expected to be ')[]('
Another expressions to validating:
// True
<s>HTML is a programming language</s>
(1+2) * (3+4) / 4!
{1, 2, 3, ..., 10}
([{<>}])
// False
<}>
)[}({>]<
<[{}]><
As you guess, I want to solve a classic problem in new way... Not only parentheses, another punctuation marks such as brackets, angle brackets, and braces should be removed. (Use re.sub(r'[^\(\)\[\]\{\}\<\>]', '', expr)
to clean them)
I want to drop them in one step, but all answers are accepted...