preg_replace('/shop_rate_list\((.*)\)/s','$1',$con); 求这段正则的详解

解决方案 »

  1.   

    把shop_rate_list(......)   替换为........  即把shop_rate_list( 和右括号 ) 删掉。
      

  2.   

    shop_rate_list(这是我要的内容)
      

  3.   

    preg_replace('/shop_rate_list\((.*)\)/s','$1',$con); 
     
    1)
    '/shop_rate_list\((.*)\)/s'
    / 与 /s
    开始与结束, 加上 s 就是不区分大小写。
    shop_rate)list\( 
    因为 ( )为特殊符号,所以需要 \( \)转换.
    (.*) 所有内容。2)
    '$1' 可理解为变量, 获取 正则中 第1次 出现 ( ) 中的内容。 
    出现第1次() 则 $1 第2次 则 $2 以此类推。
    所以意义就是 获取 shop_rate_list\((.*)\),$1 既 获取 shop_rate_list() 中()内的内容