Using regexp in a repetitive manner
Afficher commentaires plus anciens
Hi,
Given the following string:
[Some text]
type="line" coords="461,461,461,487,461,487,461,489,462,490,462,492,463,493,464,494,465,495,467,495,468,496,470,496,470,496,801,496,801,496,803,496"
[Some text]
type="line" coords="461,487,461,489,462,490,462,492,463,493,496"
How can we obtain the numbers using regexp function of MATLAB? Please note that the length of numbers in the string is variable, therefore, a " universal" expression is needed here.
Thanks in advance,
Réponse acceptée
Plus de réponses (1)
line = 'type="line" coords="461,461,461,487,461,487,461,489,462,490,462,492,463,493,464,494,465,495,467,495,468,496,470,496,470,496,801,496,801,496,803,496"'
data = sscanf(strrep(line, 'type="line" coords="', ''), '%d,');
line = 'type="line" coords="461,487,461,489,462,490,462,492,463,493,496"';
data = sscanf(strrep(line, 'type="line" coords="', ''), '%d,');
Catégories
En savoir plus sur Characters and Strings 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!