Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- preg_replace('/b^(true|false|TRUE|FALSE)b/', '', 'false'); // Returns an empty string, but i expect 'false'
- preg_replace('/b^(true|false|TRUE|FALSE)b/', '', 'test') // Returns 'test', but i expect an empty string
- preg_replace('/b^(true|false|TRUE|FALSE)b/', '', 'This regex allow only boolean, such as true, false, TRUE and FALSE');
- // This regex allow only boolean, such true, false, TRUE and FALSE
- $arr = array('true', 'false', 'TRUE', 'FALSE');
- $result = (in_array($str, $arr, true)) ? $str : '';
- $re = '/b(?!(?:true|false|TRUE|FALSE))w+b/';
- $str = 'I need true to allow only false specific FALSE words in a TRUE string';
- $repl = preg_replace($re, "", $str);
- //=> true false FALSE TRUE
- if (preg_match('/^(true|false|TRUE|FALSE)$/', $string, $match)) {
- echo "Found : ",$m[1],"n";
- } else {
- echo "Not foundn";
- }
- $regex = '/(?=.)(true|false|TRUE|FALSE|\s{0,})(?!.)/';
- $testString = ''; // Fill this in
- preg_match($regex, $testString, $matches);
- // the $matches variable contains the list of matches
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement