I’m trying to come up with a lightning fast solution to find portions in a string. Here is a Sample string:
“PostLoad successful! You transferred amount of 17.00 Rs to 03334224222. Now use PostLoad by dialing 123. PostLoad on SMS will end on 01-03-2011.”
Objective: Need to retrieve the bold values: Amount and Cell Number. The string contents change slightly but the cell number will always be a 11 digit. The amount is always with two decimal precision. Any suggestions using C# and RegEx?
Explanation:
Group #1 will contain the decimal number, group #2 will contain the 11-digit number.
A “word boundary” is the position between an alphanumeric character and a non-alphanumeric character, so it only matches at the start or end of a “word or number”.
This ensures that numbers like
12.3456will not be matched; on the other hand, it is necessary for the numbers to be delimited by whitespace, punctuation or other non-alnum characters. For example, innumber12.34the regex would not match12.34.