Good morning you lovely lot,
I have a theoretically simple regex extraction, but it is slaying me. If one of you would be so kind as to assist, it would be greatly appreciated. You'll see below the event that the extraction is required from. Essentially, we require to capture the 'role(s)' that a user may have. The opening tag is and then the role itself is contained within . The issue is that is used throughout the events and also that a user may have one, or multiple roles. As such, the regex requires to capture the first role found after and then subsequently each other role if found before terminating on .
I've gotten close-ish, but cannot capture each role individually, instead either the first, last or ALL values between the tags of 'items'. Please help as it's absolutely ending me - I'm not exactly great with regex as it's all fairly new to me.
Event Sample:
/><jobtitle>Digital Content</jobtitle><emarketingoptout /><contactpref /><roles><item>INVEST_IFA</item><item>PROTECT_IFA</item><item>RS_IFA</item><item>SOLICITOR</item></roles><permissions><item>INVEST_APPS</item><item>PROTECT_APPS</item><item>RS_APPS</item><item>SOL_APPS</item><item>UPDATE_PROFILE</item>
Regex so far (awful I know):
All Items:
`(<item>(?<role>[\w]*)\<\/item>+?)`
First or last depending upon greed:
`[\w\W]+((<item>+(?<role>[\w]*)\<\/item>)+)<\/roles`
....
| rex "roles\>(?<rolesfield>.*)\<\/roles\>"
| rex field=rolesfield max_match=0 "\>(?<roles>[A-Z_]+)\<"
....
| rex "roles\>(?<rolesfield>.*)\<\/roles\>"
| rex field=rolesfield max_match=0 "\>(?<roles>[A-Z_]+)\<"
Thank you for the response to4kawa, however is there no means to do this within a single regex extraction??
why? two REGEX is easy to understand and simple.
I appreciate that, I simply wondered if there was a means to achieve this via one regex extraction. Thank you for the assistance none the less.