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"]
ans =
"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}'
ans = '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')
ans =
{["v -0.618008 0.394531 -0.972656"]} {["v -0.621094 0.391446 -0.972656"]} {0×0 string} {0×0 string}
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 ?