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


Hi @somya177
You can use the below methods

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

Arivu :slight_smile:


can you give an example?


Use regex pattern [A-Z]{2}

Arivu :slight_smile:


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


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


can u please share the workflow sample?


Sequence.xaml (6.3 KB)



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?



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?