Reputation: 337
What is wrong in following regex?
$source =
"Je (1200) recycler(s) hebben een totale opslagcapaciteit van 24.000.000.
In het bestemmingsveld [2:188:7] zweven 0 metaal en 5.000 kristal in de ruimte.
Je hebt 0 metaal en 5.000 kristal opgehaald."
echo $source;
$regex = 'Je \(([0-9.]*?)\) recycler(s) hebben een totale opslagcapaciteit van ([0-9.]*?). ';
$regex .= 'In het bestemmingsveld \[2:188:7\] zweven ([0-9.]*?) metaal en ([0-9.]*?) kristal in de ruimte. ';
$regex .= 'Je hebt ([0-9.]*?) metaal en ([0-9.]*?) kristal opgehaald.';
$matches = array();
preg_match_all('/' . $regex . '/i', $source, $matches, PREG_SET_ORDER);
print_r($matches);
Upvotes: 0
Views: 343
Reputation: 5216
Je \(([0-9.]*?)\) recycler\(s\) hebben een totale opslagcapaciteit van ([0-9.]*?)\s+
\s+In het bestemmingsveld \[2:188:7\] zweven ([0-9.]*?) metaal en ([0-9.]*?) kristal in de ruimte.\s+
\s+Je hebt ([0-9.]*?) metaal en ([0-9.]*?) kristal opgehaald.
I quotes the parans in recycler(s), added some \s+ before and after the new lines and added a 's' modifier to the regex match
Upvotes: 0
Reputation: 9262
the parentheses in recycler(s)
need a backslash. try: recycler\(s\)
Upvotes: 1