How to remove parentheses from all single words in a string?

2 次查看(过去 30 天)
Example:
(G5)*((G6)*(G2+G4))+(G2)*(-(G4+G6)*(G1))+(G4)*(-(G6)*(G3))
Changes to:
G5*(G6*(G2+G4))+G2*(-(G4+G6)*G1)+G4*(-G6*G3)

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2016-6-5
编辑:Azzi Abdelmalek 2016-6-5
s='(G5)*((G6)*(G2+G4))+(G2)*(-(G4+G6)*(G1))+(G4)*(-(G6)*(G3))'
[i1,i2]=regexpi(s,'\<\([a-z0-9]+\>\)')
s([i1 i2])=[]
Or
s='(G5)*((G6)*(G2+G4))+(G2)*(-(G4+G6)*(G1))+(G4)*(-(G6)*(G3))'
out=regexprep(s,'\<\(([a-zA-Z0-9]+)\>\)','$1')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by