Ho to check if strings are surrounded by spaces : I have the following string pattern in Python:

    {{test1 | test2(a) | test3|test4}}

What I try to achieve is to check if the string contains sub-strings which are not separated by a space before/after the pipe (|).

So in this example following sub-strings should be "marked" as not valid:

 - test3 (missing space before |) 
 - test4 (missing space after |)

I tried this with a regex but had no luck...