regexp returns unwanted 0x0 string cells
Afficher commentaires plus anciens
Hello,
I have a string array c that contains :
c = ["v -0.618008 0.394531 -0.972656" "v -0.621094 0.391446 -0.972656" "n 0.064545 0.997915 -0.000000" "n 0.021679 0.999765 -0.000000"]
From that, I want to extract all the v so that my result looks like that :
["v -0.618008 0.394531 -0.972656" "v -0.621094 0.391446 -0.972656"]
To do so I use this regex expression :
'v (-?[0-9. ]+){3}'
I tried it on regex101 and it gives me the right results. However when I use it with Matlab, it gives me two unwanted empty string cells like this :
regexp(c,'v (-?[0-9. ]+){3}','match')
This is a problem because I want my end result to be an array of string so I want to use string() on this result, but string returns an error with the {0x0 string}...
Do you know how I can skip the empty string cells with the regexp function ?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Conversion 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!