I have some tests that check strings that are displayed to the user.
I don’t wish the test to fail to due to changes in the indentations or line breaks etc. So I am looking for something like a string compare that.
- Ignore while space as the start of the string (easy use string.trim)
- When any number of any type of white space that is next to each other matches in the same way as if it was a single space.
I could start to create a regex, but someone else may have a better solution hence this question.
Writing a custom compare would be tricky if you need it just to do this for whitespace.
I would suggest using regex to normalize, i.e.
Obviously normalize both operands and then test for equality as normal.