Trim the exact text

Hi, I am facing an serious issue, where I want to extract the specific text from the bulk text.

This is exception text but I alwasy want the hilighted text only.

An ExceptionDetail,
likely created by IncludeExceptionDetailInFaults=true,
whose value is:
System.Data.DuplicateNameException: A column named ‘LANGU’ already belongs to this DataTable.
at UiPath.Excel.Activities.ExcelInteropActivity`1.EndExecute(AsyncCodeActivityContext context,
IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context,
IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor,
BookmarkManager bookmarkManager)

Note: If always want a middle text from System.Data.DuplicateNameException: to at UiPath.Excel.Activities.ExcelInteropActivity

Expected output is always
A column named ‘LANGU’ already belongs to this DataTable (But the column name is always dynamic only.)
@Palaniyappan @HareeshMR @ImPratham45 @Lahiru.Fernando @lakshman kindly reply soon.

Hello @balkishan

Based on he error, it looks like you are having two columns with the same name in your data table. What exactly are you trying to do here? Can you explain your process and at what point you get this error?

1 Like

Thanks for the response bro. basically I want to extract the specif text from like A column to Data Table, I want to send this in the email body to send to the client about the duplicate. So I want to alwasy extract from the

If you see here System.Data.DuplicateNameException: A column named ‘LANGU’ already belongs to this DataTable .
at UiPath.Excel.Activities.

This alsways come whenevr exception there so I want only the middle like like A column name to Data Table.

Hope you understand bro.

Note - I always want to trim from here System.Data.DuplicateNameException:

only want the text A column named ‘LANGU’ already belongs to this DataTable

Hi @balkishan,
Using Matches activity you can put as a pattern this regex A(?=.+‘).+e
The final effect will look like this:

1 Like

oh ok… so I suppose you have this error message added to a string variable right?

After that, have you tried using a regex to get this pattern and extract the string out?

2 Likes

no I didn’t not bro

Use it in variable (say ExceptionVariable )and then
ExceptionVariable.split("Exception:"c)(1)
Op will be : A column named ‘LANGU’ already belongs to this DataTable

1 Like

Hi,

Try with this xaml, you may get idea, you need to define the from and to strings to get the between string value. This getting the correct result. Check this as well

ExtractText.xaml (6.3 KB)

Hey getting the error

Sorry for mistake
Use Split(Variable,“Exception:”)(1)

1 Like

Please find here the project example with use of regex mentioned by me couple posts above :slight_smile:
regex.zip (12.8 KB)

1 Like

It’s giving me this text.

split that tooo
Split(Variable,“Exception:”)(1).Split({" at"},StringSplitOptions.None)(0)

Or You may try as @Pablito say using Regex

Hi Thanks for the sharing sample, just a little query, I want to assing the regext result in a variable but it thrown me this exception.
image

I’ve used “text” variable as an input to Matches activity. Please make string variable with other name :slight_smile:

1 Like

I have gave my String variable only in the Input field.

Hi @Pablito I used you solution in my workflow. But based on the condition it’s not giving me any result. I can share the workflow with you no prob is you see.

You need to remember that all input provided to Matches activity must be string type. If anywhere earlier you are using any variable inside the text you need to parse everything to one solid string and only then use it in regex.

1 Like

My Match Input is only String type variable @Pablito
This is the Match Input

see this is the text come in a input string variable, And I highlighted the text in yellow color which I want, But when I use the Match output var in a write it’s giving me this red line error.

Can you share output of this variable (before regex)?

1 Like