Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Regular expressions - extract parts of a string

1 visualizzazione (ultimi 30 giorni)
Daniel Miller
Daniel Miller il 15 Ott 2019
Chiuso: MATLAB Answer Bot il 20 Ago 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!

Risposte (0)

Questa domanda è chiusa.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by