Page 1 of 1
Split string expression
Posted: Thu May 31, 2018 11:45 am
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
Re: Split string expression
Posted: Thu May 31, 2018 9:39 pm
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.
Re: Split string expression
Posted: Fri Jun 01, 2018 4:05 am
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
Re: Split string expression
Posted: Fri Jun 01, 2018 6:53 am
by Lech Kulikowski
Hello,
We have checked:
Thank you.
Re: Split string expression
Posted: Fri Jun 01, 2018 8:16 am
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
Re: Split string expression
Posted: Fri Jun 01, 2018 12:36 pm
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.