Split string expression

Stimulsoft Reports.NET discussion
Post Reply
charlvdb
Posts: 12
Joined: Fri Sep 01, 2017 5:59 am
Location: South Africa

Split string expression

Post by charlvdb »

Hi

Is it possible to have an expression in stimulsoft where you pass through a string, seperated by spaces ,to be split by the first letter of each word inside the string?

This is to gather the initials from first names.

For example;
My string is Alfa Bravo Charlie
I want the expression to return:
A B C

My C# knowledge is very limited

Thank you
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Split string expression

Post by Lech Kulikowski »

Hello,

As a way, you can use Regex:

Code: Select all

{System.Text.RegularExpressions.Regex.Replace(YourValue, @"[^A-Z,\W]", "")}
Thank you.
charlvdb
Posts: 12
Joined: Fri Sep 01, 2017 5:59 am
Location: South Africa

Re: Split string expression

Post by charlvdb »

Lech Kulikowski wrote: Thu May 31, 2018 9:39 pm Hello,

As a way, you can use Regex:

Code: Select all

{System.Text.RegularExpressions.Regex.Replace(YourValue, @"[^A-Z,\W]", "")}
Thank you.
Thank you for the response.

Using that expression my string is returned:

ALFABRAVOCHARLIE

Instead of A B C
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Split string expression

Post by Lech Kulikowski »

Hello,

We have checked:

Thank you.
Attachments
Capture.PNG
Capture.PNG (51.79 KiB) Viewed 4115 times
charlvdb
Posts: 12
Joined: Fri Sep 01, 2017 5:59 am
Location: South Africa

Re: Split string expression

Post by charlvdb »

Hi Thank you, i see it's working with that example.

I noticed my string's values will always be in UPPER case, hence not working 100% for me.

Can the expression be amended to cater for uppercase characters inside the string? My current result for ALFA BRAVO CHARLIE returns: ALFABRAVOCHARLIE
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Split string expression

Post by Lech Kulikowski »

Hello,

You can change regex pattern as you needed for your incoming string:
https://docs.microsoft.com/en-us/dotnet ... -reference

Thank you.
Post Reply