Use Regex expression to get substring

Hi y’all, I have this string and I just need the values of 4 pointers using regex. Can somebody please help me? Delivery due, Topic AND {Remove non-HMM due} will remain constant.
Input :
Delivery Due
Topic
• HMM Oversized Tshirt
• HMM Oversized Tshirt (1)
• HMM Jeans (1 - Torn)
• BMM Blazer (1)
{Remove non-HMM due}

Output
• HMM Oversized Tshirt
• HMM Oversized Tshirt (1)
• HMM Jeans (1 - Torn)
• BMM Blazer (1)

Hi @Tanmay_V_Chetule

(?<=Delivery Due[\s\S]*?)(• HMM[^{]*)
Input="Delivery Due
Topic
• HMM Oversized Tshirt
• HMM Oversized Tshirt (1)
• HMM Jeans (1 - Torn)
• HMM Blazer (1)
{Remove non-HMM due}"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=Delivery Due[\s\S]*?)(• HMM[^{]*)").Value

Hope it helps!!

what if some value doesnt start with HMM?

Hi @Tanmay_V_Chetule

Input="Delivery Due
Topic
• HMM Oversized Tshirt
• HMM Oversized Tshirt (1)
• HMM Jeans (1 - Torn)
• HMM Blazer (1)
{Remove non-HMM due}"
Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=Delivery Due[\s\S]*?)(•\s[A-Z].*)").Value

Hope it helps!!

@Tanmay_V_Chetule
Try below once

(?<=Delivery Due[\s\S]*?)(•[^\r\n]+)

Hello

Take a look here

Here is a simplified version where you can change the start and finish values.

Hopefully this helps

Cheers

Steve

When I AM USING this in UiPath, It gives out only 1st value i.e • HMM Oversized Tshirt.
Can we utilize the last line i.e {Remove non-HMM due} too for complete extraction?

@Tanmay_V_Chetule

Use the given regex in Find Matching Patterns activity and store the output in a variable. The variable is of DataType IEnumerable(Match).

You need to run a For each fir that variable and you can print the currentItem.

Hope you understand!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.