MATLAB: Read data from string

string

I have string line:
x='abc123(xyz456)'
How to read information only in brackets, to have result:
y='xyz456'.

Best Answer

>> x='abc123(xyz456)';
>> regexp(x,'(?<=\().+(?=\))','match')
ans =
'xyz456'
This command uses regexp and, specifically, lookaround assertions. It's basically saying, if you find a group of characters, look behind to see if there is an "open parenthesis" character and look ahead to see if there is a "close parenthesis" character. If so, return all the characters between them.