The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Question Using Regexpi
Replies: 11   Last Post: Jul 8, 2013 10:35 AM

Advanced Search

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

Posts: 62
Registered: 11/29/10
Question Using Regexpi
Posted: Jul 3, 2013 10:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I have a fairly easy question. I want to match numbers that occur ONLY at the end of a string. For example, I have the following string:

String = 'NR1 MGT - 61 HOURS'

I have written the following code to pull out the number '61' using the '$' to try to match the number at the end of the string:

Match = regexpi(String,'((\d*\x2C\d*\x2E\d*)|(\d*\x2E\d*)|(\d*\x2C\d*)|(\d*))$','match');

This returns an empty cell meaning that nothing could be matched. However, when I remove the '$' it returns the numbers '1' and '61' but I only want it to return the '61' because it occurs at the end of the string. I'm clearly not using the '$' operator correctly and hopefully someone can show me how to do this properly. Thanks for the help.


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.