extract numbers from string

Hi,
I'm a newby in IGOR PRO.
I'm trying to extract a number from a string for data analysis pourpose.
I use this kind of instruction:
 string COL=stringfromlist (0, lista, ";")

      string field, value, tesla, degree, kelvin

      String expr="([[:alpha:]]+)([[:digit:]]+)([[:alpha:]]+)([[:digit:]]+)([[:alpha:]]+)"
     
      Splitstring/E=(expr) COL, field, value, tesla, degree, kelvin


      variable/D B=str2num(value)


I have the string COL which is always in the form Magnetic4T77K
So the function returns field=magnetic, value=4, tesla=T, degree=77 and kelvin=K
I need the value of the value string so in this case the function works properly!

But if I have a string where the value is decimal as COL=Magnetic1.2T77K
the function does not work! It is clearly the dot creating problems!!

Can I use an alternative method to extract the value from the string or can I modify this function in some way?

Thank you
You could change the regular expression you use to the following: ([[:alpha:]]+)([-.+[:digit:]]+)([[:alpha:]]+)([[:digit:]]+)([[:alpha:]]+)

That expression allows the period, plus sign, and minus sign as well as digits in the second capturing group.

If you know you won't ever have the plus or minus sign, you could use: ([[:alpha:]]+)([.[:digit:]]+)([[:alpha:]]+)([[:digit:]]+)([[:alpha:]]+)

If you expect decimals to be in other capturing groups, you'll need to do the same thing for those groups.
If your string is always of the form Magnetic(number)T(number)K then I think sscanf would make a much clearer solution:
// arg is the string that you want to parse
// fieldStrength, temperature, are variables that you declare
// and that will be set to the correct values by sscanf

sscanf arg, "Magnetic%gT%gK", fieldStrength, temperature