The reason that there was an extra quote was it was copied from the code view.
If I try to enter the function via the editor I get this error
If I just type it into the filter query I start by typing substringof then (' I use the lightning bolt to add the triggerbody from then I enter the colum name from the table and it allows me to save the query
But when I run it, I get