Cut off Characters

Stimulsoft Ultimate discussion
Post Reply
Steff23
Posts: 16
Joined: Tue Apr 23, 2024 6:55 am

Cut off Characters

Post by Steff23 »

Hello, how can I hide or cut off characters in Stimulsoft starting from a “ “ (space)? The length of the text varies, so Stimulsoft needs to search for the space and then remove the characters after it.

For example: “Hallo Welt” — “Welt” should no longer be displayed.

I already tried that.

Code: Select all


IIF(
    Substring(EMPLOYEES.LASTNAME, 0, 1) == " ",
    Left(EMPLOYEES.LASTNAME, 0),
    IIF(
        Substring(EMPLOYEES.LASTNAME, 1, 1) == " ",
        Left(EMPLOYEES.LASTNAME, 1),
        IIF(
            Substring(EMPLOYEES.LASTNAME, 2, 1) == " ",
            Left(EMPLOYEES.LASTNAME, 2),
            IIF(
                Substring(EMPLOYEES.LASTNAME, 3, 1) == " ",
                Left(EMPLOYEES.LASTNAME, 3),
                IIF(
                    Substring(EMPLOYEES.LASTNAME, 4, 1) == " ",
                    Left(EMPLOYEES.LASTNAME, 4),
                    EMPLOYEES.LASTNAME
                )
            )
        )
    )
)
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: Cut off Characters

Post by Lech Kulikowski »

Hello,

Try to use the following expression:
{Substring(EMPLOYEES.LASTNAME, 0, EMPLOYEES.LASTNAME.IndexOf(" "))}

Thank you.
Steff23
Posts: 16
Joined: Tue Apr 23, 2024 6:55 am

Re: Cut off Characters

Post by Steff23 »

Thank you for the quick response; your approach works very well. However, I now have the following problem: If the character “ “ is not found because it is not present in the string, the entire string gets truncated/hidden.
Lech Kulikowski
Posts: 7332
Joined: Tue Mar 20, 2018 5:34 am

Re: Cut off Characters

Post by Lech Kulikowski »

Hello,

Try to use the following expression:
{(EMPLOYEES.LASTNAME.IndexOf(" ") != - 1 ? Substring(EMPLOYEES.LASTNAME, 0, EMPLOYEES.LASTNAME.IndexOf(" ")) : EMPLOYEES.LASTNAME)}

Thank you.
Post Reply