A powerful function to “decode” a fixed set of values.
textis the text to search.
textToSearch_xis the text (or regular expression) to search for.
textToReplace_xis the text that will be returned if
textToSearch_x was found,
textToReplace_x will be returned. If
textToSearch_x was not found, the same producure will
be performed on
textToSearch_x+1 until a result is found.
textToSearch_x was found at all,
fallback is returned (or an empty text,
fallback was defined.
decodeAll(description, /ladies/i, 'F', /women/i, 'F', /gentlemen/i, 'M', /men/i, 'M', 'uni' )
- “Women’s top” → “F”
- “Men’s shoes” → “M”
- “Fluffy scarf” → “uni”