Live example: https://regexr.com/4rblr
Source markup:
<xf:macro name="breadcrumbs" arg-breadcrumbs="!" arg-navTree="!" arg-selectedNavEntry="{{ null }}" arg-variant="">
<xf:if contentcheck="true">
<ul class="p-breadcrumbs {{ $variant ? 'p-breadcrumbs--' . $variant : '' }}"
itemscope itemtype="https://schema.org/BreadcrumbList">
<xf:contentcheck>
<xf:set var="$position" value="{{ 0 }}" />
<xf:set var="$rootBreadcrumb" value="{$navTree.{$xf.options.rootBreadcrumb}}" />
<xf:if is="$rootBreadcrumb AND $rootBreadcrumb.href != $xf.uri">
<xf:set var="$position" value="{{ $position + 1 }}" />
<xf:macro name="crumb"
arg-position="{$position}"
arg-href="{$rootBreadcrumb.href}"
arg-value="{$rootBreadcrumb.title}" />
</xf:if>
<xf:if is="$selectedNavEntry && $selectedNavEntry.href && $selectedNavEntry.href != $xf.uri && $selectedNavEntry.href != $rootBreadcrumb.href">
<xf:set var="$position" value="{{ $position + 1 }}" />
<xf:macro name="crumb"
arg-position="{$position}"
arg-href="{$selectedNavEntry.href}"
arg-value="{$selectedNavEntry.title}" />
</xf:if>
<xf:foreach loop="$breadcrumbs" value="$breadcrumb" if="$breadcrumb.href != $xf.uri">
<xf:set var="$position" value="{{ $position + 1 }}" />
<xf:macro name="crumb"
arg-position="{$position}"
arg-href="{$breadcrumb.href}"
arg-value="{$breadcrumb.value}" />
</xf:foreach>
</xf:contentcheck>
</ul>
</xf:if>
</xf:macro>
I'm trying to grab the ul.p-breadcrumbs element via regex. I can grab the ul and everything after ok using:
<p.*class.p-breadcrumbs(.*[\s]*)*
And I can select the closing tag with
<\/ul>
However putting them together doesn't work at all:
<ul.*class=.p-breadcrumbs(.*[\s]*)*<\/ul>
I followed this answer: https://www.regextester.com/93456
But it doesn't work with multiline content. If you line break that example and enter more content it breaks the solution. Appreciate any pointers as I'm pulling hair out trying to solve the last bit!