Quote:
Originally Posted by ownedbycats
I have a list of tags such as Fiction.Cultures & Regions.Canada and Nonfiction.Cultures & Regions.Asia.China.
I'd like to remove any tag including "Cultures & Regions" from the list before splitting it.
I tried a regex list_difference but it didn't seem to work:
Code:
program:
list_difference($tags, '(.*)Cultures & Regions(.*)', ',');)
(Additionally, I also want to do the same with something like a list_intersection to extract the culture & region items.)
|
Most of the list functions don't take a regular expression to specify the list. They require an actual list.
You can do what you want with list_re_group(). This template uses that function to return a list of items not containing "Cultures & Regions" by setting that list item to the empty string.
Code:
program:
l = list_re_group($tags, ',', '.', '(^.*Cultures & Regions.*$)', '')
You can use list_re()'s include_re to do the opposite -- extract all items containing "Cultures & Regions".