Category / Section
How to Remove Unwanted Characters from a String in Bold Reports
Published:
Updated:
BoldReports provides a convenient method to remove unwanted characters from a string using the System.Text.RegularExpressions.Regex.Replace function. This functionality allows you to customize the removal of specific characters based on your requirements.
Use the following Expression to remove the Unwanted characters.
=System.Text.RegularExpressions.Regex.Replace(Fields!YourField.Value, “[desiredCharacters]”, “”)
- Fields!YourField.Value is the expression for the field that contains the string.
- [desiredCharacters] is a regular expression that matches all characters that are not in the desired character string.
- “” is the replacement string.
Example:
In the following example, remove all characters except numbers from the string.
Expression | Output |
---|---|
=System.Text.RegularExpressions.Regex.Replace(“A123456sdfghjxcv1b2-c?~~`!@#$ %^&*()_+{}[]3d4e5f6g”, “[^0-9]”, “”) | 123456123456 |
Find the following sample report.