Page 1 of 1

Formatting string in a specific format

Posted: Fri Nov 29, 2013 10:00 am
by rlacko
Hello,
please how can I make in StimulsoftReports.Web specific format of text:

Example:
Input string: MX1025DX
Formatted output string: MX-1025-DX

Can I use ToString() or Format() function, something like ToString("##-####-##") or I need to use Substring() function?

Thank You for help.

Re: Formatting string in a specific format

Posted: Tue Dec 03, 2013 1:58 pm
by HighAley
Hello.

You could use any C# expression to get the right string. You could use Substring() or Insert() method.
As a way you could use regular expression and write next expression:

Code: Select all

{Regex.Replace(Variable1, @"([A-Z]{2})([0-9]{4})([A-Z]{2})", "$1-$2-$3")}
Don't forget to add next line in the code of report:

Code: Select all

using System.Text.RegularExpressions;
Thank you.