Escape from regex in php

1

local-config_form_settings- test To match the "test", I'm using this regex:

(?<=config_form_settings-)([a-z0-9]+)

I tested the regex here: link and it's the way I want it. In php I'm using preg_quote to escape from capture groups:

if (preg_match(preg_quote("(?<=peerreview_form_settings-)([a-z0-9]+)"), $result['name'], $matches) == true) {
  print("Match");
}

But this way do not match anything. Anyone know what the regex problem is?

    
asked by anonymous 26.09.2016 / 21:33

1 answer

2
if (preg_match(preg_quote("(/?<=peerreview_form_settings-)([a-z0-9]+)/"), $result['name'], $matches) == true) {
  print("Match");
}

/ was missing to indicate the beginning and end of the regular expression.

    
26.09.2016 / 21:37