0 votes

As this Regex will demonstrate I'm a bit of a regex noob, but it does work in https://regex101.com/ where I put it together. I am looking to search for any files that have either SELECT * FROM foobar OR SELECT foobar.* FROM foobar. The following regex works in the testing area on the website:

[S][E][L][E][C][T][\s]*(foobar\.\*|\*)*[\s]*[F][R][O][M][\s]*[f][o][o][b][a][r]

but when I use that in AS it will only capture the sequence when it is on one line. When it's formatted with tabs and linebreaks it can not find it.

I imagine /s is not the correct character to use here, what should I be using instead?

by (40 points)

1 Answer

+1 vote
 
Best answer

For the regex to work correctly you need to have 'Multi-line Regex' selected for the containing text expression type (FileLocator Pro feature):

Multi-line regex

Also, you don't need the square brackets if there's only one character in the list, e.g.

SELECT\s*(foobar\.\*|\*)*\s*FROM\s*foobar

by (30.1k points)
...