Consider the following Pattern
expression:
keysLevel1Pattern={_,
XMLElement[_,_,{_,XMLElement[_,_,{_,XMLElement["h2",{"class"->"level-title"},{x_,XMLElement[_,_,{y_}],_}],_}],_}],
_,
XMLElement[_,_,{_,
PatternSequence[XMLElement[_,_,{_,_,_,_,XMLElement[_,_,{_,XMLElement[_,_,{_,XMLElement["h3",{"class"->"course-title"},{_}],_,_,_,_,_}],_,_,_}],_}],
_]..
}],
_}:>StringRiffle@StringTrim[{x,y}]->{};
If I run it as follows it works fine and is able to capture all the required sub expressions:
Cases[pageXML,keysLevel1Pattern,∞]
But I want to exact something from each PatternSequence
that matches and collect it in a list. So I try the following modification:
keysLevel1Pattern={_,
XMLElement[_,_,{_,XMLElement[_,_,{_,XMLElement["h2",{"class"->"level-title"},{x_,XMLElement[_,_,{y_}],_}],_}],_}],
_,
XMLElement[_,_,{_,
PatternSequence[XMLElement[_,_,{_,_,_,_,XMLElement[_,_,{_,XMLElement[_,_,{_,XMLElement["h3",{"class"->"course-title"},{z_}],_,_,_,_,_}],_,_,_}],_}],
_]..
}],
_}:>StringRiffle@StringTrim[{x,y}]->{z};
But this doesn't work.
So my question is, is there a way to nicely refer to each z
that matches in the PatternSequence
without using nested Cases
?