cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Extract Regex Values Action

PeterLomi
Level 3
I am facing an issue with using the Extract Regex Values action.  There is very limited documentation provided for this action.  I've done some research and made some progress, but I am not able to make the last connections to solve this problem.  I'm hoping someone will be able to help, and I thank you all in advance. I am able to generate a Regex pattern that extracts the correct data from my Target String, but I am unable to get it to work within Blue Prism.  From my research, it appears that I need to reference the value that I'm looking for in the Regex pattern itself.  I€™m not sure how to do that, and could use some direction. My Target String is a multi-line, variable text string called "Address Block".  Here's an example: "     JAMES JOHN JONES JR                                 135 GRANDERSON AVE                                                                                                                           ANYTOWN                       NY                    99999                                    " I am trying to extract the 2-character State ("NY" in the example above), which I am calling Address State.  I have referenced Address State in the Name field on the Initial Values tab of my input collection "Named Values".  My Regex pattern (shortened for readibility) is "\s(CT|MA|ME|NH|NY|RI|VT)\s\s".  Results are output to the same collection "Named Values". My question is: How do I reference Address State in this Regex pattern, so that the Extract Regex Values action will work properly? Thank you. Peter Lomi
3 REPLIES 3

JasonEtchason
Level 3
The tldr; is that you need to use named groups in your regex and pass a collection with those names defined in the collection.   The long of it: First, you need to modify your use to capture the result in a ""Named Group"".  (You can google ""regex named groups if you are unfamiliar with this concept. Using your shortened regex, something like this should work: ""\s(?CT|MA|ME|NH|NY|RI|VT)\s\s""   Then you need to create a collection (refered to as ""NamedValues"" for reference). This collection NamedValues needs to have two fields defined, both as type Text: Field 1) Name Field 2) Value   Now, pre-populate NamedValues with one row for every named group you want to capture and fill in the ""Name"" field with the names used in a regex named group.  In this example we're only looking for state, so you would have just one row with Name set to State (minus quotes).  You can leave the field Value as empty here.   Now, in your ""Extract Regex Values"" action, update the input fields to include the collection NamedValues (in the input field ""Named Values""). And update the output field ""Named Values"" to pass to either the same collection, or a collection with the same form (or no definition). That should be it.  Cheers    

JasonEtchason
Level 3
The tldr; is that you need to use named groups in your regex and pass a collection with those names defined in the collection.   The long of it: First, you need to modify your regex to capture the result in a ""Named Group"".  (You can google ""regex named groups if you are unfamiliar with this concept.) Using your shortened regex, something like this should work: ""\s(?CT|MA|ME|NH|NY|RI|VT)\s\s""   Then you need to create a collection (refered to as ""NamedValues"" for reference). This collection NamedValues needs to have two fields defined, both as type Text:   Field 1) Name   Field 2) Value Now, pre-populate NamedValues with one row for every named group you want to capture and fill in the ""Name"" field with the names used in a regex named group.  In this example we're only looking for state, so you would have just one row with Name set to State.  Leave the field Value as empty. Now, in your ""Extract Regex Values"" action, update the input fields to include the collection NamedValues (in the input field ""Named Values""). And update the output field ""Named Values"" to pass to either the same collection, or a collection with the same form (or no definition). That should be it.  Cheers    

PeterLomi
Level 3
Thank you for your help.  It was the Named Group part that I was missing.