Formatting string in a specific format

Stimulsoft Reports.WEB discussion
Post Reply
rlacko
Posts: 11
Joined: Fri May 24, 2013 10:39 am

Formatting string in a specific format

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Formatting string in a specific format

Post 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.
Post Reply