Cell/Row Color - Text Conditions


I've wanted to experiment with conditional cell and row coloring. I can understand working with numerical values and conditions ( sales > 5 etc.) but what I'd like to do is expose data where there is some formatting issue with text.

The scenario I'd give is that I'm importing a .csv and loading it into a table. I'd then like to perform some conditional formatting and highlight those rows which may contain some data issues; in this case, I'd like to highlight cells where there are unwanted spaces at the beginning or end of a string.

Are any of you able to help me with this? I'm sure some regex might be needed but my limited knowledge of JS and functions to handle strings is what's holding me back a bit here...

Thanks in advance.

{{ currentRow.Surname.startsWith(" ") ? 'red' : ''}}


Think I'm on my way with this now... any advice on how to do this with a regex and how to check for spaces at the start and end would be great!

{{ /^[a-zA-Z0-9!@#\$%\^\&*\)\(+=._-]+$/g.test(self.trim()) ? '' : 'orange'}}

Sorted :+1: