How to extract Words from Text that Contains a Given String?

Dears,
How to extract Words from Text that Contains a Given String ?
Example ; I want to extract all words in bellow text that contains “fo” or “in”

UiPath is a global software company for robotic process automation (RPA)
founded in Romania by Daniel Dines and Marius Tîrcă and headquartered in New York City.
The company’s software monitors user activity to automate repetitive front and back office tasks,
including those performed using other business software such as customer relationship management
or enterprise resource planning (ERP) software.

OUTPUT Should be :

1) Words that Contains “fo” :
for
founded
performed

2) Words that Contains “in” :
in
Dines
in
including
using
business
planning

Thanks in Advance

@hsendel - Please check this…

1 Like

Thanks a lot @prasath17 for prompt feedback.
As I understand need to use RegEx Activities, but how to extract those words to an external Database?

what you mean by this??

1 Like

How to get an output as follows :
1) Words that Contains “fo” :
for
founded
performed

2) Words that Contains “in” :
in
Dines
in
including
using
business
planning

@hsendel - Again…I asked what you mean by “how to extract those words to an external Database?”

You wanted to extract those words and write it to an Output file??

1 Like

Hi @hsendel
Apart from using regex, you can try the string manipulation

Assuming the string data in input_text variable, you can try these assign activity to get the words containing fo and in

data_1=System.Text.RegularExpressions.Regex.Split(input_text,“\s+”).Where(Function(l) l.ToString.Contains(“fo”)).ToArray

data_2=System.Text.RegularExpressions.Regex.Split(input_text,“\s+”).Where(Function(l) l.ToString.Contains(“in”)).ToArray

To add to external database, use sql activities in uipath.Database.Activities
image

Regards,
Nived N
Happy Automation

2 Likes

Hi @hsendel ,

You can use @prasath17 regex pattern in below highlighted activity to get the result.

image

1 Like

@hsendel - Here is a sample…

1 Like

Exact!!!

Can you share the code ?

@hsendel - Please try to mimic as shown below, in this way you will easily able to grasp the things…

1 Like

I’m a bit late here but I feel like regex may be a bit too much here. I would instead suggest using a LINQ query.

If you have your text as text, then you can easily do text.Split(' ').Where(x => x.Contains("fo") || x.Contains("in")) to grab all of the words.

3 Likes

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