After a few hours of experimenting with http://www.phpliveregex.com/ - I have become rather stuck. I am looking for a regular expression that would satisfy the following example criteria:
arrname = array('blackberry', 'apple', 'orange', 'mandarin');
arrname = array('****11111', '2%%%2', '3$$$$33', '444£££44');
So essentially it boils down to the following pattern:
[arrname = array('] [any characters] [', '] [any characters] [', '] [any characters] [', '] [any characters] [');]
Where any character is literally any (letter / number / symbol) - in any order (but requires a length of at least 1 character) - hence the need for a regular expression using the preg_match()
function.
My trouble is making the regular expression match the pattern stated above (repeated below).
[arrname = array('] [any characters] [', '] [any characters] [', '] [any characters] [', '] [any characters] [');]
UPDATE:
Having tried to implement preg_match()
I've failed and am obviously missing something really stupid (errors listed below). Any idea's?
First (using double quotes on the expression)
$pattern = "arrname = array\('([^']+)', '([^']+)', '([^']+)', '([^']+)'\);";
preg_match($pattern, $data, $matches);
Gives me the error Warning: preg_match(): Delimiter must not be alphanumeric or backslash
Second (using single quote on the expression)
$pattern = 'arrname = array\('([^']+)', '([^']+)', '([^']+)', '([^']+)'\);';
preg_match($pattern, $data, $matches);
Gives me the error Parse error: syntax error, unexpected '('