MATLAB: Regexp to pull numerics only

MATLABregexp

I'm using regexp to pull a version number from a text file:
returned = string(regexp (filetext, '(?<=Version_String )[A-Z]*\d*.\d*.\d*.\d*', 'match'))
This returns a string
"YZ1.1.2.3"
which is good.
When I try and extract just the numbers and decimal point from this string with
version = regexp (returned, '\d*.\d*.\d*.\d*', 'match')
I get:
version = 1x2 string array "YZ1.1" ".2.3"
which is not what I was expecting. I was hoping for 1.1.2.3
Can someone explain why this is returned and possibly how to fix it please?
edit: Apologies to all, I missed the decimal points after the \d, I have corrected. I wrote this on my phone in my lunch break!

Best Answer

    • \d*\d*\d*\d* is exactly the same as \d*, match 0 or more digits. It probably would be better as \d+, match 1 or more digits
    • That regular expression cannot return anything with letters or dots in it, so it's clearly not what you are using.