Create a regex expression with operator 'AND'


/ Published in: PHP
Save to your folder(s)

Build a regex expression to all array elements are present in any order.
Gets an array of strings (Sample: array("Access Denied","error","could not be retrieved")
Return sample: '(?=.*Access Denied)(?=.*error)(?=.*could not be retrieved)


Copy this code and paste it in your HTML
  1. function regex_and($array)
  2. {
  3. return '(?=.*'.implode(')(?=.*',$array).')';
  4. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.