On 11/13/2012 3:56 PM, Kevin Ellis wrote: > Hello, > > I have a question regarding parsing strings. Suppose I have a string: > > S = '42.714 GAL OF SMALL BOAT FUEL @3.699 PER GAL.' > > I have been trying to figure out a way to remove the numbers 42.714 and > 3.699 from the string. I have tried using 'sscanf' and 'regexp' to do > this. Using regexp I can find the index of the numbers: ...
Is the text fixed or variable?
If it's fixed and simply values change you can use
x = sscanf(S,'%f GAL OF SMALL BOAT FUEL @%f');
sscanf() isn't flexible in mixing conversion of string and numeric values but textscan() can.
In regexp the expression needed would be (assuming F format,not E)