Info
This question is closed. Reopen it to edit or answer.
Regular expressions - extract parts of a string
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (0)
This question is closed.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!