Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Parsing Strings
Replies: 3   Last Post: Nov 13, 2012 7:19 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Kevin Ellis

Posts: 51
Registered: 11/29/10
Parsing Strings
Posted: Nov 13, 2012 4:56 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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:

idx = regexp(S,'\d')

idx =

1 2 4 5 6 32 34 35 36

But this is not working because the decimal point is not being identified. For my problem, it is not safe to assume that the character in index 3 is always a decimal point. It may just be a blank space. Thus, I was wondering if there was a better way to approach this problem. Again, I am simply looking to remove the numbers from the string (decimal point included). Any help would be much appreciated.

Kevin



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.