<p>If I have a query such as <code>SELECT * from authors where name = @name_param</code>, is there a regex to parse out the parameter names (specifically the "name_param")?</p>

<p>Thanks</p>

This is tricky because params can also occur inside quoted strings.
```
```
SELECT * FROM authors WHERE name = @name_param 
  AND string = 'don\'t use @name_param';
```
```
How would the regular expression know to use the first
```
@name_param
```
but not the second?
It's a problem that can be solved, but it's not practical to do it in a single regular expression.  I had to handle this in Zend_Db, and what I did was first strip out all quoted strings and delimited identifiers, and then you can use regular expressions on the remainder.
You can see the code, because it's open-source.
See functions
```
_stripQuoted()
```
and
```
_parseParameters()
```
.
https://github.com/zendframework/zf1/blob/136735e776f520b081cd374012852cb88cef9a88/library/Zend/Db/Statement.php#L200
https://github.com/zendframework/zf1/blob/136735e776f520b081cd374012852cb88cef9a88/library/Zend/Db/Statement.php#L140