Extract only specific part from a string

i have a string containing address and i want to pick only state/province from it which will always be two alphabets.please suggest.
house no.1,Abc street
Berlin,ON, L65X1W

I have to pick only ‘ON’ from this whole address string.
Please suggest

1 Like

Hi @somya177
You can use the below methods

  1. regex
  2. substring
    3 split method you can check each value

Arivu :slight_smile:

1 Like

can you give an example?

1 Like

Use regex pattern [A-Z]{2}

Arivu :slight_smile:

1 Like

how we will display the result of it?
Like i just want ON from the whole string to be displayed.

1 Like

Split the string on new line, then on comma character and get the second element

1 Like

can u please share the workflow sample?

Sequence.xaml (6.3 KB)

1 Like


I am getting below error
Assign: Index was outside the bounds of the array.


I am getting below error.:

Source: Assign

Message: Index was outside the bounds of the array.

Exception Type: System.IndexOutOfRangeException

No error here… Did you run my sample or it gives an error after adapting in your flow?


1 Like

in my flow,there is space and not comma.
so i replaced comma with space IN SPLIT function in order to make my workflow work.
it is: BERLIN ON L65X1W

Great, if it’s working

no…its giving the previous error

Then post the exact input file/text here…

this is the exact input;


i just want to extract ON from this.

Should work as I have written it, replacing comma with space. The difference might be the newline character. I think the error is on the first split. Check there.

should i should not do first step?

first split should be done on new line?

is there any way to use it using substring?