Hi there,
Not sure if this is possible with a regular expression replace command, but I have an existing regex replace which will convert the last two digits of a number to the same last two digits prefixed with a full stop. This is for interfacing to a system which sends through currency values as "2500" where this represents "25.00" dollars.
My existing regex: (\d+)(\d{2})$
With replace syntax of: $1.$2
Now I have a problem though, if a value is sent through as "50" only for example, this could represent 0.50 and my regex will fail because it is searching for 1+ numeric on the left, and two numeric exactly at the end of the string.
How could I cover all these circumstances and have my regex replace replace thusly:
2500 = 25.00
500 = 5.00
50 = 0.50
5 = 0.05
Thanks again, Graham
Update: For those asking why this cannot be a divide and string format job is because I have to avoid custom programming to achieve this. It must ideally be a regex "rule" defined in a database along with other regex definitions as it's being used for a generic translation system. It will translate incoming data which could come in multiple format types, generally translating a field from "101" to "101A" for example, but in this particular case for this data type, adding values is required.
Second update: I've been thinking more about this, because I am bound to a database, would anybody see a better way than using a %wackyMoney% or some other 'token' defined in the db field and then test if we hit this token in code to apply the C# string formatting and divide?