- important: . does NOT match the period character, but in fact it matches any character. To only match the period, you need to escape it: \.
- \d matches any digit, and is simpler than writing [0-9]
- by making the decimal fraction optional my answer will also match integer values
using regexp with negative and positive floating numbers
169 views (last 30 days)
% 11x1 cell
to remove the non-numeric character;
data_num = regexp(data,'[0-9]+.[0-9]+', 'match');
In this case, negative signs (-) are also removed. How can I modify this code to get - signs?
Stephen23 on 24 May 2017
Edited: Stephen23 on 24 May 2017
Read the MATLAB documentation for more information:
You might also like to try my FEX submission, which lets you experiment with regular expressions and see their output in real time (as you type):