cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Extract Regex Values Action

PrasadM
Level 3
Hi, I am trying to use "Extract Regex "Action in utility-String object, but it is not working as expected. I have the working Regex pattern and I need to extract Regex values from a string (ie and Zip code from an address using Regex), It Requires an Input collection of named values and output of resultant collection which is confusing help will be appreciated . Regards, Prasad
4 REPLIES 4

Anonymous
Not applicable
I do understand your confusion. Let me try to explain. You need a collection with two fields ""Name"" and ""Value"", both of type text(this will be created automatically if you create the data item directly from the output in Action Properties). You have to start out by setting initial values corresponding to the Group names, that you will use for the extracted values. Let me illustrate by an example: Say you want to extract ""Phone No."" and ""Name"" from the following target string: Employee: John Country: Italy Phone No.: 1234567890 You could use the expression ""Employee:\s(?[^\n]*).*Phone No.:\s(?\d{10})"". Now the collection ""Named Values"" should be initialized with initial values. Name:Employee Value: Name:Phone Value: After running the action, the collection Named Values will be updated, and (Name,Values) pairs should correspond to the match for each group (given that you use the default names for the input and output collection). I haven't tested this particular example, but it should give you general idea how to use this action. Note that I define a group by enclosing a subexpression in brackets and prepending the group name, using the following syntax: (?regex). You can read up on grouping constructs and backreferencing here: https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#groupi

Carol.Ouellet
Level 5
Hello, I've tried Indika Engholm's example and got it to work after some trial and errors - thanks. I want to point out that the ""Named Value"" collection for Input and Output must be the same Collection object or have at least the same column names (Name and Value), otherwise it will return empty values. I wish the documentation was more than a simple description of the variables. For the sake of having examples and help understanding I added my test process. If the attached image doesn't work: http://i.imgur.com/F8WLeO2.png

Hi Carol, If you could share me as how did you end up successfully running the Regex object, it would be of great help to me . Thanks, Prateek

PeterLomi
Level 3
I am facing a related issue.  Like the OP, I was also confused by the limited documentation provided for the Extract Regex Values 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.  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