Extract word between two known words

regex

#1

Hi
Is there any way to read a particular word which is between two known words with the help of regex?
eg If input is Name ABCD Age, I need to extract ABCD.

Instead of using substring function, is there any way we can utilize any regex?


Extract Text Between Labels
How do I have multiple matches activity with different pattern to read?
#2

Hi,

try this (?<=Name\s).*(?=\sAge)
This is a Lookbehind(Name) and Lookahead(Age)

BR,
Topi


#3

Hii
Thanks for quick reply.
I’m sorry as I’m new to regex but where exactly would I use this expression in UiPath?
I mean if I have a variable which holds the string and another one which holds the substring, how will i assign the result of this regex to the substring variable?


Regex Missing out 1 special character
Regex issue! not getting intended output
Regex issue! not getting intended output
#4

(?<=" + labelBefore + “)(.*?)(?=” + labelAfter + ")

Extract Text Between Labels.xaml (7.1 KB)

Regards…!!
Aksh


Copy specific text
#5

Thanks a ton. This works!!


#6

Hello Aksh, do you have a Regex Tester reference ?


#7

Hey @marcus

There are many sites exists but i prefers mostly https://regex101.com/ you can also give it a try :slight_smile:

Regards…!!
Aksh


#8

What if we have 1234 instead of ABCD in between ??
or rather 12200.00?


#9

@Robo

did not get u. even the number you are looking then it will be inside a string so it will work with that and then if needed can convert this to int.

*Correct me if I m getting it wrong.

Regards…!!
Aksh


#10

Hi
Is there any way to read a particular word which is between two known words with the help of subscript()?
eg If input is Name1Name ABCD Age,
I need to extract ABCD.
Note-Using Subscript only


#11

Try something like this in Invoke Code activity,

Dim St As String = “string pulled from the textfile suing reader which has key : text I want to keep - end of my string”
Dim pFrom As Integer = St.IndexOf("key : ") + "key : “.Length
Dim pTo As Integer = St.LastIndexOf(” - ")
Dim result As String = St.Substring(pFrom, pTo - pFrom)

Note: “key :” and " -" are the two string of the string’s starting and end which we need to search and get.
we can return the result to the workflow and can use it


#12

Hi
Is there any way to read a particular word which is between two known words with the help of subscript()?
eg If input is Name1Name ABCD Age,
I need to extract ABCD.
Note-Using Subscript only


#14

Guys,

Just a question, How did you manage to associate to put the variable type “System.Collections.Generi.IEnumerable<System.Tex.RegularExpressions.Match>” on the variable “matchValue”?

I tried to find on the main directory but I cant find the same one. Is there something that I should do on the variable itself for it to work.


#15

Hi Aksh,

I’m not able to extract words as intended, can you look at below content and xaml file as to where is the problem?

rfp-scope-ui.xaml (6.8 KB)
LWSystems-UI.pdf (59.5 KB)