Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Regular expressions - extract parts of a string

1 Ansicht (letzte 30 Tage)
Daniel Miller
Daniel Miller am 15 Okt. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 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!

Antworten (0)

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by