Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?php // Positive lookahead: price before " USD" preg_match_all("/\d+(?= USD)/", "100 USD and 250 USD", $m); // $m[0] = ["100", "250"] // Negative lookahead: digits NOT followed by " USD" preg_match_all("/\d+(?! USD)/", "100 USD 200 EUR", $m); // Positive lookbehind: digits after "$" preg_match_all("/(?<=\$)\d+/", "$100 and $250", $m); // $m[0] = ["100", "250"] // Negative lookbehind preg_match_all("/(?<!\$)\d+/", "$100 200 items", $m);
Result
Open