# Trim

The Trim action statement is used to remove characters in fields, a named variable or fields listed in a named variable. More information is given in Statement Source/Target Determination regarding the runtime determination of which items to trim. When the functionality is accessed by the Multi Field Editor it only characters in fields.

You select which sets of characters are to be processed. Selected sets are accumulated. The following sets are supported:

> Whitespace
>   Spaces and tab characters
> Newline
>   Line termination characters. LF (0x1A), VT (0x1B), FF (0x1C), CR (0x1D) and unicode NEL (0x85). Note that other Unicode newline characters may be included in this set.
> Punctuation
>   Commas, periods, etc.
> Control
>   Characters in the ranges: U+0000 to U+0019, U+001B to U+001F and U+007F to U+009F. All characters considered to be invalid Unicode characters are also removed. Note that while the newline character U+000A (linefeed) and tab U+0009 character are control characters they will not be removed by this set. If you want linefeed characters removed you must also specify the Newline set. If you want tab characters changed to spaces you can specify the Whitespace set and use the Change to option.
> Alphanumeric
>   All characters which can be considered letters or decimal digits.
> Decimal
>   All characters which can be considered decimal digits.
> Letters
>   All characters which can be considered letters.
> Lower Case
>   All characters which can be considered lower case letters.
> Upper Case
>   All characters which can be considered upper case letters.
> Latin-1
>   All visible characters in the Latin-1 character set encoding.
> ASCII
>   All visible characters in the ASCII character set encoding.
> Custom
>   The Trim action statement adds all unique characters in named variable Trim Custom Character Set. The Multi Field Editor can directly define the content of the custom set.

If the Inverted modifier is selected, the effective character set is inverted. As an example if you select Whitespace and Alphanumeric and Inverted, the effective set is all Unicode characters except those which are whitespace or alphanumeric. Typically the Latin-1 or ASCII set would only be specified along with this option. They provide a convenient means of allowing characters such as + and $ which are not included in any of the other sets.

You can normalize all newline sequences to the Mac standard of U+000A (linefeed). CRLF and LFCR sequences are converted to a LF character. Any remaining newline characters are converted to a single LF. This function is performed prior to any other functions.

You can optionally remove all characters, characters at the start of the field (leading) or at the end of the field (trailing) in the specified set.

You can also replace all multiple sequences of characters in the specified set with one space or newline character.

When trimming the Comments, Lyrics, Terms of Use, Commercial Information Webpage, Official Artist/Performer Webpage or Rating fields only the default items are modified. If you would like the trim operation to modify all of items for any of these field types, select the Deep modifier. The option has no effect on other field types or named variables. Note that User Defined Text Info and User Defined URL items will only be trimmed if the deep modifier is specified.

It probably never makes sense to use the Deep and as lists options at the same time.

When executing an action in stepwise execution mode and you're trimming a named variable, the statement is only performed once. The variable name is constructed at runtime. The supplied name field can contain any of the escape sequences described in Escape Sequences.

Field Selection Modes in Tables