Extract string between two strings

Hello guys

I am struggling with how to extract a dynamic string between two particular string!

Example:

ID. No: 01
NAME: Singh, Aryan
Location: Johannesburg, SA
Category: xyz

I only want “Singh, Aryan” from the above String. “Name” and “Location” will always be static!

Can anyone help me?

@Palaniyappan
@ImPratham45

Thanks and Regards
Aryan

2 Likes

Use regexp with the expression below

1 Like

Hi
the expresion be like this
str_output =
System.Text.RegularExpressions.Regex.Match(str_input.tostring,“(?<=NAME:).*(?=Location))”)

where str_input is a variable like this

str_input = “ID. No: 01
NAME: Singh, Aryan
Location: Johannesburg, SA
Category: xyz”

str_input = String.Join(“”,Str_input.Split(Environment.Newline.ToArray()))

then use the above the expression with a assign activity
Cheers @AryanSingh

9 Likes

regexBetweenLabel.xaml (5.4 KB)

System.Text.RegularExpressions.Regex.Match(strInput,“(?<=NAME:)([\S\s]*)(?=Location:)”).Value.Trim

Thanks!

6 Likes

Try this

Variable.Split({“NAME:”},StringSplitOptions.None)(1).Trim.Split({“Location”},StringSplitOptions.None)(0)

4 Likes

@Palaniyappan
@ImPratham45
@kadiravan_kalidoss

Thanks guys, I tried all the methods, each and every one of the methods are working.

Thanks & regards
Aryan

1 Like

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