How to extract string between two different strings?

Hello All,

Origin string is <OPTION value=0 selected>A</OPTION><OPTION value=1 selected>B</OPTION><OPTION value=2 selected>C</OPTION>

How to extract string between > and <?
I want to extract A,B,C and store in array using Assign activity.
Please give me some advice :slight_smile:

@anhyojin0424, try this regular expression:

(?<=>)\w(?=<)

Is it right to input String1.split("(?<=>)\w(?=<)"c) in Value of Assign Activity??

String1 is variable name storing origin string! :slight_smile:

@anhyojin0424,

i think you will run into an error, you can use the “Matches activity” parse in your variable (String1) as an input, and use the above expression put it inside " " and then create an output variable from the matches property, your varibale could be for example “Matches_Results” that will return a collection, you can then use Matches_Results(0).ToString that will give you the first alphabet and so on.

so you can use a for each activity and parse in Matches_Results insite the for each you can use write line and say “Item.ToString” that will print out all the alphabets (A,B,C) then you can decide what to do with them.

Let me know if you need further assistance.

Failed to select the desired value :sob:

@anhyojin0424, guess i wasn’t clear enough :grinning:

here is an example:

Example.zip (18.9 KB)

1 Like

@anhyojin0424,

Matches property

Matches

1 Like

Hey @anhyojin0424

you can also use this pattern

Check the below tested link

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