Marco Alka oh you mean <spaces> test ? To be honest I wondered how I should interpret this (because it was in this list, but test was in yellow there, so I understood this as we should catch the test but not the spaces .....
All to say that, as usual, requirements based on examples are always a recipe for bad things (I so often push back on our so-called tech-product specialist who always explains the features we need to build only with examples.... this drives me crazy! But that’s another story ;-)
In that case I’d go for a generic way to check for repetition with \1 and restrict it for lines, e.g:
^\W?(test)\W?( \1)?$
(railroad diagram tinyurl.com/y3etlp3q )