$re = '/(coffee|pots?)(?:\n)/m';
$str = 'import re
string = """
All I want is a proper cup of coffee
Made in a proper copper coffee pot
I may be off my dot
But I want a cup of coffee
From a proper coffee pot
Tin coffee pots and iron coffee pots
They’re no use to me
If I can’t have a proper cup of coffee
In a proper copper coffee pot
I’ll have a cup of tea.
"""
pattern = r\'coffee\\n|pot\\n|pots\\n\'
print(re.findall(pattern, string))';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php