Search code examples
crystal-reportsreport

crystal report fomula to remove ampersand at the beginning or end of the string


Need a crystal formula that would remove ampersand if any at the begging and end of a string. But not do anything if there are no ampersands at the begging or end of the string. There will be ampersands in the middle but want those to be displayed on the report. Thanks

The string would look something like this &Sample1&Sample2&Sample3& I need to change it to show Sample1&Sample2&Sample3


Solution

  • you can create a formula and write this inside:

        if left({your field}, 1) = "&" then right({your field}, len({your field})-1) 
    else {your field}
    

    then create another formula like:

        if right({your 1st formula}, 1) = "&" then left({your 1st formula}, len({your 1st formula})-1) 
    else {your field}.
    

    place 1st formula suppressed in a section above than the 2nd one will be displayed.