Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Regular expressions - extract parts of a string

1 visualización (últimos 30 días)
Daniel Miller
Daniel Miller el 15 de Oct. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi!
I have a problem I'd need some help with.
I have the following code:
randomText = 'Madrid 2.7 Milano 3.85 Berlin 0.9 Lugano -2 Rome 12 Paris 9.2'
My task is to extract only the numbers (with dots included), and to do it I have written a code that looks like this:
Solution = regexp(randomText, '\d+\.\d+','match')
However, this only extracts the four numbers with dots (2.7, 3.5, 0.9 and 9.2) but ignores the -2 and the 12. How could I change my expression to extract all the numbers?
Thank you in advance for any help!

Respuestas (0)

La pregunta está cerrada.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by