- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
<?php
//(?=) - positive lookahead
$string = "achei quebra; tem aqui;";
$regex = "/\w+(?=;)/";
preg_match_all($regex, $string, $matches);
var_dump($matches);
//(?!) - negative lookahead /
$regex = "/\b\w+\b(?!;)/";
preg_match_all($regex, $string, $matches);
var_dump($matches);
//(?<=) - positive lookbehind
$string = "dra Julia \ndr Marcos \ndr Mateus \ndra Ana";
$regex = "/(?<=dra\s)(\w+)/im";
preg_match_all($regex, $string, $matches);
var_dump($matches);
//(?<!) - negative lookbehind
$regex = "/(?<!^dra\s)\b\w+\b$/im";
preg_match_all($regex, $string, $matches);
var_dump($matches);
/*
(?>) - atomic group
*/