finding indices in a string
14 次查看(过去 30 天)
显示 更早的评论
how can i find the indices of the leading zeros in this string: '123 0009 90'
0 个评论
回答(2 个)
Adam
2016-12-16
idx = strfind( str, ' 0' );
will find you the start of each leading 0. Then you can count the zeros after each of those before a 'proper' number.
strsplit( str, ' ' );
will divide up your string into each component also, but getting the indices from that would be a tedious process so probably not too helpful.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!