Replacing a word in a string during run time

I have PDF Output saved in string. I want to search for word “TAT X Hours” where X is <=72 hours. How Do I achieve this ?
In PDF it could be any TAT X Hours

@raygandhit

if condition:StrPdfText.Contains(“TAT X Hours” )<=72 hours

then
your actions

Hi @raygandhit

Try this syntax:

If
    System.Text.RegularExpressions.Regex.IsMatch(str_PDFText,"TAT.*Hours")
Then
       Assign-> variable= System.Text.RegularExpressions.Regex.Match(str_PDFText,"(?<=TAT\s+)\d+(?=\s*Hours)").Value
          If       
           CInt(variable.ToString)<=72
         Then
            \\Do required process
          Else
            \\Do required process
End If

If the above condition does not work, provide the text that is present in X place. I will help you out.

Hope it helps!!

1 Like

@raygandhit

You can use this regex

TAT (([0-6]?\d{1})|7{1}[0-2]{1}) Hours

If you want in if condition to check for match then use

System.Text.RegularExpressions.Regex.IsMatch(str,"TAT (([0-6]?\d{1})|7{1}[0-2]{1}) Hours")

If you want to extract the value

Requiredvalue = System.Text.RegularExpressions.Regex.Match(str,"TAT (([0-6]?\d{1})|7{1}[0-2]{1}) Hours").Value

Here str is the string returned from get pdf text

Hope this helps

Cheers

There is one more problem, we have multiple occurrences of TAT X Hours, we need first occurrence in string

Hi @raygandhit

The above syntax will take the first match only.

If possible provide the sample text I will help you with flow.

Regards

Hi @raygandhit

"(?<=TAT\s+)\d{1,2}(?=\s+Hours)"

Store the output in the firstmatch property

Hope it helps!!

Test.pdf (56.2 KB)
Attached is sample of PDF
In PDF that TAT 72 Hours will change from PDF to PDF

@raygandhit

image

System.Text.RegularExpressions.Regex.Match(currentItem.ToString,"(?<=TAT\s*)\d+.*").Value

After TAT it has another value like 82 it can extract all values

if you don’t want HOURS then change the regex pattern to “(?<=TAT\s*)\d+(?=\s*\w+)”

Hi @raygandhit

Check out the below workflow:
Sequence22.xaml (9.0 KB)

If
  System.Text.RegularExpressions.Regex.IsMatch(str_Text,"TAT.*HOURS")
Then
   Assign-> variable= System.Text.RegularExpressions.Regex.Match(str_Text,"(?<=TAT\s+)\d+(?=\s*HOURS)").Value
    If
        CInt(variable.ToString)<=72
    Then
            Message Box-> "TRUE"
     Else
           Message Box-> "FALSE"
   End If
End If

Hope it helps!!

Can you reshare the xaml, Attached one is invalid

Hi @raygandhit

Check the below zip file

BlankProcess29.zip (195.9 KB)

Hope it helps!!

Gives me empty value

Hi @raygandhit

Check out this:

Regards

@raygandhit

Could you please give all possible cases of inputs .so it will be easy to write regex for you

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