Remove whitespaces parser
Configuration options
- Remove whitespaces - Replaces groups of spaces and tabs with a single space and removes whitespace from the beginning and end of the text.
- Remove new lines - Replaces groups of line breaks with a single space.
Clean repeated spaces and tabs
Page formatting can introduce extra whitespace around a value.
Source:
Large blue widget
After Remove whitespaces:
Large blue widget
This is commonly useful for values extracted with a Text selector.
Remove line breaks
Enable Remove new lines when text that is visually wrapped across lines should be returned as one line.
Source:
Free delivery
Ships tomorrow
Result:
Free delivery Ships tomorrow
Use the two options together
Enable both options when the source contains a mixture of spaces, tabs and line breaks and the desired result is one normalized line of text.
Do not remove meaningful structure unintentionally
Whitespace can sometimes carry useful meaning. Addresses, descriptions, specifications or list content may be easier to process when line breaks are preserved.
Only remove new lines when the output should genuinely be returned as one line.
Parser order
Remove whitespaces is commonly placed near the end of a parser chain so it cleans spacing left behind by earlier transformations.
Raw value
→ Replace text
→ Strip HTML
→ Remove whitespaces
If another parser relies on line breaks as separators, run that parser before removing new lines.
When not to use it
If the unwanted text is not actually whitespace, use Replace text or Regex match instead. Remove whitespaces should not be used to compensate for a selector that is extracting unrelated surrounding content.
Troubleshooting
- If separate values become joined, check whether Remove new lines should remain disabled.
- If leading or trailing spaces remain, confirm that Remove whitespaces is enabled.
- If a later parser stops matching, check whether it depended on whitespace or line-break structure that was removed earlier.
- Use the preview to compare the field before and after normalization.