Regexp parentheses string parsing issue

I have a string that looks like:
'Hello (string_here.d) (string)'
I've messed with regexp for the last hour trying to get the 'string_here.d' from within the parentheses with no avail. I thought '([.]+)' or '\([.]+\)' would work, but them I thought it was the '.' causing me trouble so I tried '([.]+\.d)' and '\([.]+\.d\)'. I tried about 100 different variations of the above. What pattern would get me the string in the parentheses that has the . character in it.

 Akzeptierte Antwort

per isakson
per isakson am 14 Mär. 2014
Bearbeitet: per isakson am 14 Mär. 2014

2 Stimmen

Not the most robust expression, but it works in this case
str = 'Hello (string_here.d) (string)';
cac = regexp( str, '(?<=\()\S+(?=\))', 'match', 'once' )
returns
cac =
string_here.d

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 14 Mär. 2014

Bearbeitet:

am 14 Mär. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by