Nintex Connect

The Official Community Site for Nintex Software Products, including Nintex Workflow 2007, 2010 and 2013; Nintex Workflow for Project Server 2010; Nintex Reporting 2008 and Nintex Analytics 2010; Nintex Forms 2010; Nintex Live and Nintex SmartLibrary.
Welcome to Nintex Connect Sign in | Join | Help
in Search

Regular expression - I think

Last post 07-19-2011, 1:58 AM by KMR. 7 replies.
Sort Posts: Previous Next
  •  06-29-2011, 1:14 PM 17857

    Regular expression - I think

    I have a field in a SharePoint list that contains a string:

    1)some text,2)some more text,3)sometimes text

    The numbers and punctuation are included in the string as noted.  The text following 1) 2) and 3) are all varying length, but always separated with commas. I need to parse this string into two variables:

    Variable1=All the text between 1) and the first comma

    Variable2=All the text between 2) and the next comma (before 3)

    I don't need to capture the text in 3).  I think I need regular expressions to do this.  I've done quite a bit of other Nintex work - but never used the regular expression.  I not sure how to start because several of the expressions appear to perform the same functions.  Maybe something like this for the first variable? 

    1)\b.*,

    And for the second?

    2)\b.*,

    Would someone point me in the right direction please?  Thanks

  •  06-30-2011, 1:16 AM 17869 in reply to 17857

    Re: Regular expression - I think

    Hi kdavis4,

    i don't know the regex you need, but when I need to play with some regex's, I use this site: http://gskinner.com/RegExr/

    Amongst others like : http://regexlib.com/CheatSheet.aspx

  •  06-30-2011, 2:15 AM 17870 in reply to 17857

    Re: Regular expression - I think

    Hi kdavis4,

    You are right with using a regular expression for this. For your scenario I would recommend to use the regular expression with 'split' operation. As comma is the separator in your string you have to define the pattern with ','. The result you must store in a workflow variable of type 'Collection'.

    As result your string is then saved in three values in the workflow variable, looking like this some text;some more text;sometimes text.

    The next step is getting the required parts out of this workflow variable. For this purpose you can make use of 'Collection Operation' action with 'Get' operation. To configure this action you have to create three workflow variables:

    • Variable 1 - for Index (Type: Number)
    • Variable 2 - for the first string (Type: Text)
    • Variable 3 - fot the second string (Type: Text)

    Then add the following actions:

    1. add a 'Set a variable' action and define 'Variable 1' with '0' to point to 'some text' in your collection variable.
    2. add a 'Collection Operation' with your collection variable as target collection, index: 'Variable 1' and store result in: 'Variable 2'.
    3. add another 'Set a variable' action and define 'Variable 1' with '1' to point to 'some more text' in your collection variable.
    4. add another 'Collection Operation' with your collection variable as target collection, index: 'Variable 1' and store result in: 'Variable 3'.
  •  07-13-2011, 1:28 PM 18107 in reply to 17870

    Re: Regular expression - I think

    hi KMR

    i have a similar problem, i do this solution, although the collection has many itmes, the workflow has a mistake :"The property of the index is bigger than the quantity of elements in the collection."

    can you help me please?

  •  07-14-2011, 2:57 AM 18117 in reply to 18107

    Re: Regular expression - I think

    Hi Moniksepu88, 

    A standard scenario for this error is the collection empty. Usually this happens when a query list action in front of the collection operation has not received any result and therefore the collection contains no element. In this case a 'Get' operation with an index '0' (pointing to the first element in the collection) will cause this error, as this would require at least one item.

    To find out how many elements are stored in your collection variable:

    1. Add a workflow action 'Collection opertion' in front of your 'Collection operation' with the 'Get' operation.
    2. Configure this 'Collection operation' with the 'Count' operation against your collection and store the result in a workflow variable of type number.
    3. Add a workflow action 'Log in the history list' to write the count workflow variable into it.
    4. Publish and run your workflow and check the result.

    Compare count value with the index value. If count is less than or equal to index the error will occure.

    Filed under:
  •  07-18-2011, 9:39 AM 18192 in reply to 18117

    Re: Regular expression - I think

     Thanks KMR!

    I can solve this problem

  •  07-18-2011, 10:30 AM 18198 in reply to 18117

    Re: Regular expression - I think

    Thanks KMR, i have another wory, it is possible to create sub-list in sharepoint? i want to achieve something like:

    List A:

       field 1:text

       field 2: number

       field 3: SubListA

    SubListA1

       field 1:text

       field 2: number

    When a user create a new item in List A, he can create several items in SubList A1.

    Thanks!

  •  07-19-2011, 1:58 AM 18228 in reply to 18198

    Re: Regular expression - I think

    Hi Moniksepu88,

    in SharePoint it is possible to establish cross links between list. In your case you could create a lookup field in List A pointing to a field (e.g. ID)in SubListA1 and vise versa using lookup fields. You could use Nintex Workflows to update this lookup fields when new entries in SubListA1 are created.

    But this is definitely a different topic than regular expressions ;)

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems