These days there are many good online tools for testing and learning regular expressions.
I like debuggex.com . Here is what it displays for your regular expression:
^\s*(?:delete|drop|truncate|alter)

Demo version of Debuggex
To interpret this, you still need to do your homework, for example, to find out what ^ and \s mean, but the "railway diagram" helps show that it is testing the regular expression. Just follow the lines to see what happens. You can also try entering test lines at the link above to find out how it matches (or doesn't).
Another good site is regex101.com . Here is your regular expression there . They give you a description in English of what the regular expression is looking for.
Also, follow mkoryak's advice on trying to sanitize SQL on the client!

source share