I want to extract the data between two fields without spaces or any special characters using regex

here is the input code:

a
aCover
aProperty All Risk
a
aName of the Insured
aM/s. Gulf Oil Middle East Limited (Jebel Ali Branch)
a
aScope of Cover
aCoverage as per the Standard Policy (LM7 Wordings).
a
aOccupancy
aResidential Property

Output: I need to extract Property All Risk ,M/s. Gulf Oil Middle East Limited (Jebel Ali Branch),Coverage as per the Standard Policy (LM7 Wordings),Residential Property.

please help me with this.
thanks in advance:)

Hi @praveena.nadi ,

Could you check with the below Regex Expressions :
Cover :

(?<=\baCover\r?\n.).*

Name of the Insured:

(?<=\baName of the Insured\r?\n.).*

Scope of Cover:

(?<=\baScope of Cover\r?\n.).*

image

Occupancy:

(?<=\baOccupancy\r?\n.).*

image

1 Like

@supermanPunch
Hey thank you very much, its working when i check using regex editor but not with the input file where i am reading the file using read text activity and storing it in Word_Text and assigning a string variable to the below expression
System.Text.RegularExpressions.Regex.Match(Word_Text,“(?<=\bCover\r?\n.).*”).Value

Could you please check by following the above methods and please let me know where am i going wrong

thanks:)

@praveena.nadi

Please try like this

System.Text.RegularExpressions.Regex.Match(Word_Text,"(?<=\bCover\r?\n.).*",RegexOptions.MultiLine).Value

@Anil_G

Hey, thank you but did you check the expression with the below input file?

Its not working when i store data into this file and reading from it. Could you please try to extract fields from the above file

thanks:)

@praveena.nadi

When I checked yes it is not working like that this is what is working

System.Text.RegularExpressions.Regex.Match(Str1,"(?<=\bCover\r?\n?.)[A-Z a-z]*(?=\r)").Value

image

cheers

@Anil_G

But its not working in my regex editor. could you check once in https://regex101.com/

thanks

@praveena.nadi

Please change flavour to c# and it would work as expected

And also there is a BEL special character when getting data from file directly for handling it added a .(dot)

cheers