How to extract using regex

Hi,

I need extract the only below selected lines using Regex. Above and below lines are not constant.

Thanks,

Does the ‘uga:SendEmail’ at the beginning and end stay the same? Also, could you paste the text instead of a screenshot? It’s easier for me/us to work with that way.

1 Like

<uga:SendEmail AttachmentList=“{x:Null}” Bcc=“{x:Null}” Body=“{x:Null}” Cc=“{x:Null}” ContinueOnError=“{x:Null}” Subject=“{x:Null}” To=“{x:Null}” AuthScopesInvalid=“False” DisplayName=“Send Mail Message” sap:VirtualizedContainerService.HintSize=“354,369” sap2010:WorkflowViewState.IdRef=“SendEmail_1” IsDraft=“False” IsHTML=“False”>
uga:SendEmail.Attachments
<scg:List x:TypeArguments=“InArgument(x:String)” Capacity=“0” />
</uga:SendEmail.Attachments>
</uga:SendEmail>

Hi @Prasaanth_S2

Can you share the whole text and is <uga:SendEmail and </uga:SendEmail> constant for those lines. Please specify.

System.Text.RegularExpressions.Regex.Match(Input,"(\<uga\:SendEmail[\s\S]*?\<\/uga\:SendEmail\>)").Value.Trim()

Hope you understand @Prasaanth_S2 !!

Regards

@Prasaanth_S2

Try this in assign

Requiredstring = System.Text.RegularExpressions.Regex.Match(fullstringhere,"(?=\<uga:SendEmail AttachmentList).*(?>\</uga:SendEmail\>)").Value`

Cheers

text is a XML with Namespaces. Therefore we recommend to work with XML oriented options instead of with Regex. Handling XML Namspaces have a look here:
XML Extraction - Handling Namespaces (Tableau, Soap, OASIS types) - Help / Community - UiPath Community Forum

UPD1 - Additional Suggestion:
as the XML also looks like a XAML maybe you can elaborate more on the overall goal