Regex Match issue

I have a problem. I need to find all the numbers which comes after the Voucher. I am using (?<!Voucher)\d+ but its selecting all the numbers.
few string example are below

  1. Your DriveAway Car Hire Voucher UK 5138695 - DOE, JOHN
  2. Attn: 1348326_2 - Voucher # 4193400 Client: PERKINS

The number can be from 5-8 letters and I only want to select the first grop after Voucher.

Any help will be appreciated

Hi,

Can you try the following pattern?

(?<=Voucher\D*)\d+

Regards,

Thanks Yoichi but its not working in Regular Expression (https://regex101.com/)

Hi,

regex101 is not 100% compatible with .net regex.
Can you try it in regex wizard of matches activity or .net compatible regex test site?

Regards,

1 Like

Hey @ravindar.singh

@Yoichi’s pattern works fine :slight_smile: Yoichi is a Regex Master!

2 Likes

Thanks Yoichi really appericate your help.
You are a legend and life saver

1 Like

Hi,

Can you try to use Assign activity as the following?

strVar =System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Voucher\D*)\d+”).Value

Regards,

1 Like

it worked thanks again :slight_smile:

I am using this will this work - (?<=Confirmation\D)\d+|(?<=Voucher\D)\d+****

I came across another scenario.Hopefully you can help me out here too.
While looping through each row Sometime the string have number but not the Voucher(specific word). How to extract that as well?

String - Your Booking Confirmation 19107756 - SWANEPOEL, PIETER. Number will always fall after Confirmation.

Type of Strings -
1.Your Booking Confirmation 19107756 - SWANEPOEL, PIETER
2.Your DriveAway Car Hire Voucher UK 5272953 - HANNEY, JOHN
3.Attn: HELIO - Voucher # 293866 Client: PHAYER

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=(Voucher|Confirmation)\D*)\d+”).Value

Regards,

Thanks yoichi

1 Like

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