0

Works in regex101

https://regex101.com/r/hAKpmr/1/

I tryied to use the pattern (?<=page=).*(?=&) in text: 'page=123&test=ok'

My code php:

preg_match('(?<=page=).*(?=&)', 'page=123&test=ok', $matches);
print_r($matches);

But had no matches and this warning: preg_match(): Unknown modifier '.'

ZeNeto
  • 41
  • 4
  • 2
    You need to add leading and trailing delimiters: `preg_match('/(?<=page=).*(?=&)/', 'page=123&test=ok', $matches);` – Tangentially Perpendicular Sep 16 '21 at 23:29
  • As you can see on regex101, the input field where you enter your regex has a slash on the left and a slash on the right with some modifiers afterward. You need to include these aswell. Please note, that not all of these modifiers can be used in PHP. – stui Sep 16 '21 at 23:33

0 Answers0