What is the Regex Pattern to find a part of the text?

Hi All,

I would like to know the regex pattern to extract “First Name” from below text. It is a column name.
Sort by:
First Name
Sorted: None
Show actions

Any help would be appreciated :slight_smile:

Hi @Vaishnav_Tej ,

We don’t see any value for the First Name field, Is the Value present next to it or is it present in the Next Line ?

If it is present next to it, then you could use the below Expression :

(?<=First Name).*

It is present in the next line exactly as shown

@Vaishnav_Tej ,

Did you want to extract in the below way :

(?<=Sort by:\r?\n).*
1 Like

Yes, Thank you.

May I know how to learn regex?

@Vaishnav_Tej ,

We already have the Tutorials listed here :

1 Like

Hi @Vaishnav_Tej

Try this one-

\bFirst Name\b

Thanks!!

1 Like

How to replace all the column names in the excel or DataTable using regex?

image

You can try this-

Read the Excel file and store the data in a DataTable variable. Use a For Each activity to iterate over the columns in the DataTable. Set the TypeArgument property to `System.Data.DataColumn.Within the For Each loop,use an Assign activity to update the column names using regex.

item.ColumnName = System.Text.RegularExpressions.Regex.Replace(item.ColumnName, pattern, replacement)

Thanks!!

2 Likes

Hi Nitya,

I’m getting error as shown below .