Regular Expression Problem , Please Help
Afficher commentaires plus anciens
I have no idea how to do this ..
str = '[a,b,c,d,e,[f1,f2],g],[u,v,w,[x1,x2],[y1,y2],z]';
Using this code:
regexp(str,'\[.*?(\[.*?\],[.*?\]).*?\]','tokens');
i got an answer like this:
ans =[f1,f2],g],[u,v,w,[x1,x2]
but what I want is like this:
ans = [x1,x2],[y1,y2]
Réponses (1)
Walter Roberson
le 27 Sep 2012
0 votes
Remember, .* will match everything including [ or ] characters. You need to exclude those characters from the search if you are looking for the ] matching a [ .
1 commentaire
Yowh
le 28 Sep 2012
Catégories
En savoir plus sur Whos dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!