How to make pattern string in preg_match_all
问题 How to make one pattern string for preg_match_all() function If I have multiple strings to match like "G,C,D" & "A,B,C" & "E,C,D" Currently my string is $str = "/(?<=\b)([CDEFGAB](?:b|bb|m)*(?:#|##|sus|maj|min|aug)*[\d\/]*(?:[CDEFGAB](?:b|bb|m)*(?:#|##|sus|maj|min|aug)*[\d\/]*)*)(?=\s|$|(<.*>))(?! \w)/" preg_match_all($str,$lyrics , $output_array); I want to add these combinations ("G,C,D" & "A,B,C" & "E,C,D") in $str string. 回答1: NOTE this answer has been dramatically edited over time to