View Full Version : [SOLVED] php regex for finding SQL parameters

March 8th, 2012, 10:44 PM
I'm trying to write a regex in PHP for finding parameters in a postgresql SQL statement. Basically, I need a regex for finding words that start with one and only one colon, since typecasting in postgresql can use double colons. For example, in this SQL statement:

SELECT entree_name, cost::money FROM menu WHERE meal=:meal

I would want the regex to grab "meal" but not "money".

What I have so far is this:


But of course that grabs "money" too.

Any ideas?

March 8th, 2012, 10:49 PM
I figured it out.

I needed: