I love regex and I hate regex at the same time.
I certainly do not know it on a good enough level, but my adventures with creating and developing things with PHP have certainly helped strengthen the "relationship" I have with regex. It's a necessary
ITT are bits, pieces and various patterns that might be useful for me and others.
# Finds one word before and after keyword in order to find frequent pairings as well. preg_match_all("/(?i)(\w+)\W+$word\W+(\w+)/", $data, $matches, PREG_SET_ORDER); /* find all pairings */
$pattern = "/(\b[a-zA-Z'\-]+\b)/"; /* find all words not including numbers or punctuation */
# This is not the best way to say the least. Splitting the text by "---" is probably better. preg_match("'^---(.+?)---'si", $str, $yaml); # Get header preg_match_all("'(\w+):\s?(.+)'m", $yaml, $yaml_attribs, PREG_SET_ORDER); # Get attributes