Extract part of text from a string

Hi,

I have a question about the best way how to split the following type of text:

Client ID: FY17206
Client Name: Bradford Cleaver
Client Country: Romania

I need to extract just ID, Name and Country…

Do you have some ideas hot to make it the most easy?

Thank you very much

Tereza

Hi @Tereza_Steflova,

You can use Regex activity,

In Assign activity take String variable in TO and in value System.Text.ReqularExression.Regex.Match(“YourString”,"(?<=Client ID: ).+").Value

Same can be used for other two.
i.e System.Text.ReqularExression.Regex.Match(“YourString”,"(?<=Client Name: ).+").Value

System.Text.ReqularExression.Regex.Matches(“YourString”,"(?<=Client Country: ).+").Value

please find the screenshot for your further understanding.

Morecenhanced regerx for all the items:
(?<=Client\s?(ID|Name|Country):) ?[a-zA-Z 0-9]+

image

Hi, Thank you very much…but for some reason it is not returning any value, this is the part of the workflow I used:

image

I used your expression as: System.Text.RegularExpressions.Regex.Match(clientDetails,"(?<=Client Name: ).+").Value

But write line activity does not show any result as an output…

Hi @Tereza_Steflova,

can you check your input string?

I have used the similar approach and getting the exact output
image

@Tereza_Steflova - Because instead of using .Matches(because you are extracting multiple value here, not one) you are using .Match , that’s the issue… Please see below…

In the For Each Loop :

StrMatches is image

Hope this helps…