Regular expression to handle dynamic strings

Hi,
I’m extracting text from multiple pdf files and single character in text file keeps changing. Is there any regular expression to handle this?
Eg. text file 1 - string appear as “Insurance policy amount” (small L)
text file 2 - string appear as “Insurance poIicy amount”(Capital i)
text file 3 - string appear as “Insurance policv amount”.
I’m retrieving the details from text file and save it in excel. If I want to retrieve “Insurance policy amount” how to handle this?

Hi @Lalitha_Selvaraj

Can you provide a sample text file.

Regards

Hi @vrdabberu . Please find the sample text file.
insurance.txt (129 Bytes)

What should be extracted from these 3 strings:

  1. Insurance PoIicv Amount: $1,200,000.00
  2. Insurance PoIicy Amount: J25 1 000 i00_
  3. Insurance Policy Amount: ##5##Q00##0 __

String1 output?
String2 output?
String3 output?

Regards

I have a field in pdf “Insurance amount” and I need to extract the value of insurance amount. pdf image
image
While extracting pdf text into text file. Field name (Insurance amount) is changing as mentioned earlier. Is there any regular expression to handle all the type of field names.
Expected results is the value available near Insurance policy amount.

Hi @Lalitha_Selvaraj

Please try the below regex expression:

(?<=\.\s*[A-Za-z ]+\:\s*)(.*)

Regards

@Lalitha_Selvaraj

You can use this regex to get policy amount

1 Like

It’s Working. but i have another field like “Amount” so its taking those values too.

It’s not working @vrdabberu. Can you give some other regex if possible.

The word “Insurance” and “Amount” is constant. only the word “policy” keeps changing.

Hi @Lalitha_Selvaraj

Is the above expected Output?

Or is the below one the expected output:

Regards

image

Hi @Lalitha_Selvaraj

Try it in Regexr website:
Pattern: (?<=\.\s*)[A-Za-z ]+(?=\:\s*)

Regards

It’s working. but this is very general. Is it possible to add “Insurance” and “Amount” keyword in the regex to make it more specific.

@Lalitha_Selvaraj Share all input string and expected output

Hi @Lalitha_Selvaraj

Try this then:

Insurance[A-Za-z ]+Amount

Regards

Sorry for the confusion. I need the right side value(highlighted ones) with “insurance” and “amount” constant regex.

Hi @Lalitha_Selvaraj

(?<=\.\s*Insurance[A-Za-z ]+Amount\:\s*)(.*)

Regards

1 Like

Great. Its working @vrdabberu. Thanks

1 Like

You’re welcome @Lalitha_Selvaraj

Happy Automation !!