I'm searching for all SELECT * like queries in my code base to replace it with the actual name of the columns.
I'm trying to build a regex that can find if a '*' is found between the word SELECT and FROM.
This should match the following patterns :
#1 SELECT * FROM tablename
#2 SELECT tablename.* FROM tablename
#3 SELECT tb1.col1, tb2.* FROM table tb1, table2 tb2
But not this one :
#4 SELECT col FROM table
My attempts so far (in the search box of PhpStorm):
SELECT *
Output: 1, 2, 3 and 4
I also tried the answer from Regex Match all characters between two strings
(?<=SELECT)(.*)(?=FROM)
Output: 1, 2, 3 and 4
I went further in StackOverflow and found this one:
SELECT\s+?[^\s]+?\s+?FROM\s+?[^\s]+?\s+?WHERE.
Output: 1, 2, 3 and 4
Can you help me please ?