Blue Prism Product

last person joined: 9 hours ago 

Chat about Blue Prism products
Expand all | Collapse all

Regex pattern

  • 1.  Regex pattern

    Posted 01-18-2021 06:58

    Hi all,
    i've a collection field with dynamic column name but always with ONE row.
    I need to check if this row contains at least one "YES" value.
    I didn't want to loop through each collection, so my idea is to use:
    1) Get collection as CSV (in that case i have one text data item with all values separated by a comma) but now, how can i check if at least one value after comma (,) is YES?
    Can i use a regex pattern?

    Thanks in advance



    ------------------------------
    Vrat Himbo
    ------------------------------


  • 2.  RE: Regex pattern

    Posted 01-18-2021 09:47
    I think you can use the below  Action under Collection Manipulation
    You can put collection name, column name and exact value you wish to search. and there is a flag output which would provide the result if the value exists inside the collection




    ------------------------------
    Harshit Rawat
    ------------------------------



  • 3.  RE: Regex pattern

    Posted 01-18-2021 09:57
    Thanks @Harshit Rawat,
    unfortunately, i haven't the same column name, only the values and first row are fixed.
    Like this:
    Column1?? Column2?? Column3?? Column4??
    YES              NO              YES             NO

    And i need to check if at least one value of the first row is yes. I don't want to use a loop, so i've tried to convert collection to CSV (text) but i don't know how can i check it, with regex or in other way​

    ------------------------------
    Vrat Himbo
    ------------------------------



  • 4.  RE: Regex pattern

    Posted 01-18-2021 10:36
    Hi Vrat,
    As you said you have taken the text into a data item please share your thoughts for the below approach
    ​The data item contains the text separated by ",". I am just checking if either ",YES" or "YES," are present in the data item . IF the Decision yields Yes this means the text data item contains your value.
    @Vrat Himbo

    ------------------------------
    Harshit Rawat
    ------------------------------



  • 5.  RE: Regex pattern

    Posted 01-18-2021 10:45
    Thanks for your solution.
    The only problem is if i have a column with the name starts with YES.
    For example Column1??,YES+*Column2,NO,NO,NO

    ------------------------------
    Vrat Himbo
    ------------------------------



  • 6.  RE: Regex pattern

    Posted 01-18-2021 10:07
    This should suffice as a regex pattern: \s{0,}\"{0,}YES\"{0,}(,|$)

    It ensures the entire cell content is YES, so "YESTERDAY" wouldn't match, and it also discards any leading spaces or if it is surrounded by quotation marks that some CSV formats will throw in there. Keep in mind it'll match if a column is called "YES" as well, so it might be wise to trim the header line off before running this.

    Personally, I'd shoot for a more reusable option; you could create an action that takes a collection and searches for any values. With a code stage you'd be able to iterate over all of the fields in the collection and make sure it's a proper match as opposed to a regex search.

    ------------------------------
    Nicholas Zejdlik
    RPA Developer
    ------------------------------



  • 7.  RE: Regex pattern

    Posted 01-18-2021 10:47

    Thank you, i've tested the regex but in this case it match also with a column name that contains YES, is correct?
    I can do it in C#? Do you know if there is something already done?
    Is possible to use a LinQ Expression to check it?


    Thanks in advance



    ------------------------------
    Vrat Himbo
    ------------------------------



  • 8.  RE: Regex pattern

    Posted 01-18-2021 11:13
    Can use C# and Linq. If you use Linq in a code stage, make sure to add a reference to System.Linq.dll and the System.Linq namespace in the global object code. Since collections are a DataTable in a code stage, you'll have to call AsEnumerable() on it to be able to use it in a Linq expression, for example:

    found = table.AsEnumerable().Any(row => {
    	foreach (DataColumn col in table.Columns) {
    		if (row[col].ToString() == valueToFind) {
    			return true;
    		}
    	}
    	return false;
    });​


    ------------------------------
    Nicholas Zejdlik
    RPA Developer
    ------------------------------



  • 9.  RE: Regex pattern

    Posted 01-18-2021 11:53
    Thanks for the reply.
    I put in input Datatable & ValueToFInd (text), a boolean in output, imported System.Linq.dll and the System.Linq. And i've imported system.data.datasetextensions. But i've this problem. How can i fix it? Thanks


    ------------------------------
    Vrat Himbo
    ------------------------------



  • 10.  RE: Regex pattern

    Posted 01-18-2021 12:16
    I've imported System.core.dll and now it seems to work, is that correct? @Nicholas Zejdlik

    ------------------------------
    Vrat Himbo
    ------------------------------



  • 11.  RE: Regex pattern

    Posted 01-18-2021 12:21
    Aye, that would do it. Whenever you use C# you'll want to add the System.Core.dll reference.

    ------------------------------
    Nicholas Zejdlik
    RPA Developer
    ------------------------------



FAQ

Blue Prism is intelligent automation — business-developed, no-code automation that pushes the boundaries of robotic process automation (RPA) to deliver value across any business process in a connected enterprise.

A combination of RPA with expanded cognitive and AI capabilities, Blue Prism is different than other automation technology on the market. With one Blue Prism license, you gain instant access to an already AI equipped digital workforce, along with the tools you need to build and delegate automations. Click here for more information on Blue Prism and Intelligent Automation.
To learn more about how Blue Prism can help your organization and how much it will cost to get started, please Contact our Sales department.
Blue Prism can be downloaded from our customer portal. If you would like to consume or download any material it is necessary to create an account on the Portal. Once you have registered, you can access the download options for Blue Prism here.
Yes! Installed on your own machine and supported by our training materials and product documentation, you can use all the features of the full enterprise product for free with our Blue Prism Trial – giving you the opportunity to learn the basics before moving to a full production implementation. Click here for more information and to download the trial.
Yes! You can access our known issue list for Blue Prism from our Support Portal.
Regardless of your industry, Blue Prism’s Digital Workforce can adhere to strict governance and compliance standards without limiting productivity. Click here for more information on how your industry can benefit from Blue Prism.



Share this post