Transform String processor in a Prepare recipe not removing leading whitespace
![silviutofan](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar9.png)
silviutofan
Dataiker Alumni Posts: 3 ✭✭✭✭
Getting some unusual behaviour from a "Transform String" shaker. When applied to a string column, it does not successfully remove leading/trailing whitespace. When encoding the text to UTF-8 (via the shaker), I can see that there is a non-breaking whitespace encoded there.
Is this behaviour intended? What can we do to go around this?
Is this behaviour intended? What can we do to go around this?
Tagged:
Best Answer
-
This is the expected behavior as the Trim processor uses the classic definition of whitespaces, not the extended Unicode definition (which includes the dozens of ways there exist to represent spaces).
To remove it, you have to use a Find/Replace with a regular expression
Replace:
\p{Zs}*$
By nothing
This means "any number of characters of the Zs Unicode character class immediately followed by the end of the string ($)". To learn more about Unicode character classes, see https://en.wikipedia.org/wiki/Unicode_character_property