fork download
  1. <?php
  2.  
  3. $re = '~(?<!\+)\+\+(\w+)\+\+(?!\+)~';
  4. $str = "I have ++VAR++ and +++++++++++ and +++text+++++ and ++ANOTHER_VAR++.";
  5. preg_match_all($re, $str, $matches);
  6. print_r($matches);
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => ++VAR++
            [1] => ++ANOTHER_VAR++
        )

    [1] => Array
        (
            [0] => VAR
            [1] => ANOTHER_VAR
        )

)