You are here: Functions > COMPACT()

COMPACT()

The COMPACT() function will look for multiple consecutive occurrences of a specified character or character string within a character string and replace them with a single occurrence. By default, when no character or character string is specified, the function removes all consecutive occurrences of a blank with a single blank.

This function is case sensitive.

Function Format

COMPACT(C1<,C2>)

The COMPACT() function scans a character field or expression C1 from left to right and searches for multiple consecutive occurrences of a character or character string C2. and replaces it with a single occurrence. If the optional C2 value is not specified, COMPACT() assumes a C2 value of a blank.

Examples

COMPACT("This is a test") = "This is a test"

COMPACT("Thissssss is a test","s") = "This is a test"

COMPACT("ThissSSss is a test","s") = "ThisSSs is a test"

COMPACT("This is abcabcabc now","abc") = "This is abc now"