Hi,
To validate and remove specific characters (Unicode U+200B and U+202F) from the data when it is being saved in the system, you can use Mendix microflows and string manipulation functions. Here's a step-by-step guide on how to achieve this:
Create a Microflow: Start by creating a microflow that will handle the saving of data and the validation of characters.
Retrieve Data: In the microflow, you need to retrieve the data that you want to save.
Remove Characters: To remove the unwanted characters (U+200B and U+202F) from the data, use the "Replace" function available in Mendix's expression editor. The "Replace" function allows you to search for a specific substring in a string and replace it with another value. Here's how you can use it:
For U+200B (Zero Width Space): Use the "Replace" function to replace the U+200B character with an empty string:
replaceAll($yourString, '​', '')
For U+202F (Narrow No-Break Space): Use the "Replace" function to replace the U+202F character with an empty string:
replaceAll($yourString, ' ', '')
Save Cleaned Data: After removing the unwanted characters, save the cleaned data to the database.
Trigger the Microflow: Depending on your application's logic, you need to trigger this microflow when data is being saved or updated in the system.
You can use the replaceAll function to replace certain characters. So to replace U+202f you could use the following.
replaceAll($inputString, '\u202f', '')
The first parameter is the string you want search.
The second is a regular expression, so for U+202f you would use \u202f .
The third is the character you want to replace. You may want to use ‘’ to remove the character completely or ‘ ‘ to replace with a space.
You could create a microflow that has a series of these changes and then you could use this to clean the data. You could do this using a BeforeCommit event for example so before the data is added to the database it is cleaned.
I hope this helps.