I have this regex
<SharePointWebControls:(\w+|_)+[=" _\w]*?(fieldname="(\w+|_)+")?[="' _\w<>%$:,]*?\/>
with mode gi
and I'm testing it against
<SharePointWebControls:FieldValue id="PageStylesField" FieldName="HeaderStyleDefinitions" runat="server" />
And I want to capture two strings, FieldValue
and HeaderStyleDefinitions
. However the fieldname attribute may not exist, in which case just capture the first string, but if it exists, then capture both.
But in my regex, it always only captures the first string. Does anyone know how to fix it?