Regex to find the 1st matching data between 2 different words

Hi team,

i have data like below, i need to extract the full name of 1st match between “Name:” and “ECI:” by using Regex, please help.

“KYC Summary
Ticket # : 4567856789
Date : Aug 25, 2022 2:44am
KYC type: Review
Name: Arjun M Singh
ECI: 8996909
GWM ID: f098678685
Yes X No
Type Information
Code
FirstName
Arjun
Middle Name
M
Last name
Singh
Type Information
Code
Name: Arjun M Singh
ECI:
8996909
GWM ID: f098678685
Date
Place
Code
Name: Arjun M Singh
ECI:
8996909
GWM ID: f098678685
abcd
place”

Thanks in advance…!

@Yoichi, @ptrobot Can you help me on the this regex

Hi @shaikmdrafi ,

Could you Check with the below regex :

(?<=Name:).*(?=\r?\nECI)

Expression to be used :

Regex.Matches(strInput,"(?<=Name:).*(?=\r?\nECI)").Cast(Of Match).First.Value.Trim

Hi @shaikmdrafi

Checkout this expression

For getting the full name

System.RegularExpressions.Regex.Match(InputString,"(?<=Name:).*").ToString

For getting the ECI

System.RegularExpressions.Regex.Match(InputString,"(?<=ECI:).*|(?<=ECI:\n).*").ToString

Regards
Sudharsan

Thanks Sudarsan…!, it is working fine. But when i applied the same regex by changing the keywords for other fields getting blank. Can you help me to extract the fields “Employment Status”,“Company Name”,“Position” “Duration in years” and also "Description of the business.

KYC Summary
Ticket # : 4567856789
Date : Aug 25, 2022 2:44am
KYC type: Review
Name: Arjun M Singh
ECI: 8996909
GWM ID: f098678685
Yes X No
Type Information
Code
FirstName
Arjun
Middle Name
M
Last name
Singh
Type Information
Code
Name: Arjun M Singh
ECI:
8996909
GWM ID: f098678685
Date
Place
Code
Name: Arjun M Singh
ECI:
8996909
GWM ID: f098678685
abcd
place
Employment
To update read-only employment information below, go to the Core Information tab, Client Information section and click on the edit button.
Employed
Employment Status
Employed

Company Name
IBM IIND PVT LTD.
Position
System Engineer
Duration in years
17 years 10 months

Employment Address
Address Line 1
North Michigan Avenue
Address Line 2

Address Line 3

Country
UNITED STATES
State/Province
ILLINOIS
Years of service in the industry
17

Description of the business (i.e. history of the business including notable products/services, areas of operation, and types of clients served)

Valor Equity Partners is an operational growth investment firm focused on non-control and control investments in high growth
companies across various stages of development. For decades, we have served our companies with unique expertise to solve the
challenges of growth and scale. We partner with leading companies and entrepreneurs who are committed to the highest standards of
excellence and the courage to transform their industries.

Position(s) held and tenure

System Engineer

Thanks…

@shaikmdrafi

You can try this

Str.Split({"Employment Status"},StringSplitOptions.None(1).Split({"Company Name"},Stringsplitoptions.None)(0).Trim

Repeat same for others and you shoudl have all the values

Cheers

HI @shaikmdrafi

Checkout this expressions

Employment Status

System.RegularExpressions.Regex.Match(InputString,"(?<=Employment Status\n).*").ToString

Company Name

System.RegularExpressions.Regex.Match(InputString,"(?<=Company Name\n).*").ToString

Position

System.RegularExpressions.Regex.Match(InputString,"(?<=Position\n).*").ToString

Duration in years

System.RegularExpressions.Regex.Match(InputString,"(?<=Duration in years\n).*").ToString

Description of the business

System.RegularExpressions.Regex.Match(InputString,"(?s)(?<=Description of the business \(i.e. history of the business including notable products\/services, areas of operation, and types of clients served\)\n\n)(.*?)(?=\.\s)").ToString

Regards
Sudharsan

If you want the description upto Position means use this pattern @shaikmdrafi

(?s)(?<=Description of the business \(i.e. history of the business including notable products\/services, areas of operation, and types of clients served\)\n\n)(.*?)(?=Position)

Thanks Sudharsan… for quick response, i am getting all blank for these regex, Can you check.

Thanks @Anil_G for the solution, this is also working fine.

Thanks…

1 Like

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