Regular Expressions 101

Community Patterns

There does not seem to be anything here

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(?:\G|<saml:Attribute\s*+Name="example"[^\/>]*+>)(?:\s*+<saml:AttributeValue\s*+xsi:type="xs:string"[^\/>]*+>(?<value>[^<]*+)<\/saml:AttributeValue[^>]*+>|\s*+<[^\/][^\/>]*+>[^<]*+<\/[^>]*+>|\s*+<[^\/][^>\/]*+\/>)
/
gms

Description

This regex extracts Attribute Values from specified Attribute Name.

Only known edge case is if a saml:AttributeValue tag is the first tag in the string, but it shouldn't be the case for SAML responses

It can easily adapted to do the same type of extract from an XML tag containing multiple tags containing values

Submitted by Skerilyo - 18 days ago (Last modified 17 days ago)