I’m currently developing a SMS application in vbnet. One problem I encountered is when the sim card runs out of load. So I make a function that checks the balance if sending a message failed for 3 times. Now the problem is how can i parse or get the value from the string. I know this can be done in ReGex (or you can suggest me if you have a better technique for this). This is the reply from the service provider:
Your current balance as of 02/15/2012 00:17 is P1.00 valid til...
I need to get the P1.00 from the string. And the possible valid format of the balance is:
- P1.50
- P10.00
- P100.00
- P 100.75
- P 1.00
- Php 1.00
- Php10.50
So as you can see, the pattern has a monetary symbol of P (or sometimes Php) and followed by a numeric value. Sometimes it has a white space between the monetary symbol and the value. The pattern also has two decimal places. Now how can i do this using ReGex?
I cannot show some codes since I have no (even a single) idea where should i start from. I really need your help.
From a quick test in Expresso, this should do it for you:
And as explanation: