Skip to main content
Question

In Appian, write a expression to remove every "AB" from each string, wherever it appears


Example:

Input: {"ABHello", "HelloABWorld", "WorldAB", "ABCABD"}
Output: {"Hello", "HelloWorld", "World", "CD"}

Each value starts with "AB", and the goal is to remove this prefix from every string.

A
Anonymous
April 9, 2026

Answer

Solution 1: substitute()

substitute(text, find, replace_with) swaps part of a string for another string, and the Appian community points to it as the replace-all equivalent.

a!localVariables(
local!array: {"ABHello", "HelloABWorld", "WorldAB", "ABCABD"},
a!forEach(
items: local!array,
expression: substitute(fv!item, "AB", "")
)
)

It is case sensitive, so "ab" stays. Substitution is also a single pass: "AABB" becomes "AB", because the AB that forms after the first removal isn’t removed.


Solution 2: regex

regexreplaceall comes from Appian’s free Regex Functions plug-in and isn’t built in. It replaces all matches of a pattern in the input string.

To remove every AB:


a!localVariables(
local!array: {"ABHello", "HelloABWorld", "WorldAB", "ABCABD"},
a!forEach(
items: local!array,
expression: regexreplaceall("AB", fv!item, "")
)
)

The pattern changes with where AB may appear:

/* Only at the start */
regexreplaceall("^AB", fv!item, "")

/* Only at the end */
regexreplaceall("AB$", fv!item, "")

/* At the start or the end, not in the middle */
regexreplaceall("^AB|AB$", fv!item, "")

/* Any case: AB, ab, Ab, aB (Java inline flag, test it) */
regexreplaceall("(?i)AB", fv!item, "")

/* Any two leading uppercase letters, not just AB */
regexreplaceall("^[A-Z]{2}", fv!item, "")


Solution 3: split and join

Split the string on "AB", then join the pieces back together with nothing between them.

a!forEach(
items: local!array,
expression: joinarray(split(fv!item, "AB"), "")
)

Output:

In Appian, write a expression to remove every "AB" from each string, wherever it appears Example: Input: {"ABHello", "HelloAB


Which one to use

substitute() is my default for removing exact text anywhere. Regex fits when the rule is a pattern, such as “only at the start or end” or “any two letters,” and the cost is installing the plug-in. In an interview, I’d give substitute() first, then show regex with the ^AB|AB$ pattern to show you can control position.

Try it yourself

Change the inputs or the expression and run it to see what it returns.

ri!array=

Independent evaluator: it approximates the Appian expression language and may differ from a real Appian environment. Verify anything that matters. Terms

JuniorExpressions#coding