Issue in Reading Regex value from excel

Hello Community,

I have a regex expression in excel sheet

(?<=Title="".*)\b%PlaceHolder%\b(?=.*"")

This is being read in UiPath as

(?<=Title=\"\".*)\b%PlaceHolder%\b(?=.*\"\")

Then I will have be replaceing %PlaceHolder% with My word

But i think adding those \ is not making my regex work as intended. what should i do?

How can I overcome this issue?

Thank you

Hi @hansen_Lobo

Can you send the required regex

I mean the required word

Regards

The regex in excel sheet

(?<=Title="".*)\b%PlaceHolder%\b(?=.*"")

The thing i want to perfrom

System.Text.RegularExpressions.Regex.Replace(strOriginal, "(?<=Title="".*)\bCars\b(?=.*"")", " Buses")

the %PlaceHolder% value is gonna change based on my condition

@hansen_Lobo share your string

Hi @hansen_Lobo

Store the condition that you want to pass in a variable like

-Assign -> Replaceword = Car

Store the excel regex in a variable lik

- Assign -> Regex = Currenrow("regex").toString

Pass the replaceword variable in the requireregex variable

- Assign -> requiredregex = Regex.Replace("%PlaceHolder%",Replaceword)

Hope it helps!!

Input String can be anything. But I am having issues reading that regex expression from excel because it has double quotes I guess

@hansen_Lobo
place in excel like this

(?<=Title=\"\".*)\b{0}\b(?=.*\"\")

Read this value and store in Variable as StrRegex
Then use assign value and use String Format

FinalRegex = String.Format(StrRegex,YourWord)

@hansen_Lobo did you try?

Give me five mins. will try

If you find the solution do mark it as solution to close the loop. @hansen_Lobo

Happy Automation!!

@hansen_Lobo

  1. Read the regex pattern from Excel into a variable, let’s call it regexPattern.
  2. Use the regexPattern.Replace("\\", "") expression to remove the additional backslashes from the pattern. For example:
    regexPattern = regexPattern.Replace("\\", "")
  3. Now you can replace %PlaceHolder% with your desired word using the modified regex pattern.

Further, if you are not seeing \\ in UiPath read value, you can consider the following steps:

  1. Ensure the cell containing the regex pattern in Excel is formatted as plain text. This prevents Excel from interpreting the contents as a formula or applying any formatting.
  2. When reading the cell value in UiPath, use activities that preserve the original cell format and value, such as the “Read Cell” activity with the PreserveFormat property set to True.
1 Like

No it didnt work

It read the value from excel as

(?<=Title=\\"\\".*)\b%{0}%\b(?=.*\\"\\")

let me try.
This might work

Let me know how it goes.

Unleashing the Power of Automation, One Bot at a Time!

@hansen_Lobo
After Read from excel
put assign"

FinalRegex = StrRegex.Replace("\\","\")

Now put one more assign:

FinalRegex = String.Format(StrRegex,YourWord)

Still unable to do it. Could you send the xaml if possible

Hello Raja I am Still having issues with it.

@hansen_Lobo Let my check wait.

Hi @hansen_Lobo

Could you try this process.
Store the condition that you want to pass in a variable like

-Assign -> Replaceword = Car

Store the excel regex in a variable like

- Assign -> Regex = Currenrow("regex").toString

Pass the replaceword variable in the requireregex variable

- Assign -> requiredregex = Regex.Replace("%PlaceHolder%",Replaceword)

Try this one!!

@mkankatala It is valid, when you are manipulating with in studio, when we read from excel its not giving correct values