Text Replacement using RegEx

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rmeshksar
    New Member
    • Feb 2008
    • 1

    Text Replacement using RegEx

    Hi,
    I would like to do text replacement using RegEx and use the following statement:
    Regex.Replace(i nput, pattern, replacement, RegexOptions.Ig noreCase)

    It works fine in all cases except in the following scenario.

    Replacement of a text with a curreny value:
    Example:
    decimal total = 100;
    string sTotal = string.Format(" {0:c}", total);
    string replaced = Regex.Replace(" Total = ::total::", "::total::" , sTotal, RegexOptions.Ig noreCase);

    It returns: Total = $100.00 which is fine.

    Now if the total is zero (Just Zero) it returns:
    Total = ::total::.00

    I do not know wht it does not work with zero.

    Any help would be appreciated.
Working...