php - Regex not capturing properly -


Here is a query that I want to create an array of parameters:

  $ subject = "SELECT * a_table with WHERE something = 'col1 =: param1' and col2 =: param2 or col3 =: param3";   

I tried:

  $ pattern = "^ ([\" ']) (?: (? = (\\\\?) ) \\ 2.) *? \\ 1 ^ "$ subject = preg_replace ($ pattern," "$ $ subject");   

and

  $ Pattern = '# [:] [A-zA-Z0-9 _] + # '; preg_match_all ($ pattern, $ theme, $ matches); print_r ($ matches);   

Unfortunately, I only want to Param2 and param3 found as output

I would like to see my dump like this:

  Array ([0] = & Gt ;: param1 [1] = & gt;: Ultimate 2 [2] = & gt;: param3)    

You can just use this regex = (: \ w +)

  $ query = "SELECT * to a_table Where some = '$ 1 = $; & I; $ I ++) resonate {$ params [1] [$ i]. "  

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -