Solved

NWC - import CSV and split lines using RegEx

  • 28 February 2023
  • 3 replies
  • 122 views

Badge +2

Working in a tenancy with very strict limitations, no Power Automate etc. so NWC is the only go-to.

I’m importing a CSV from SharePoint, and are trying to split the rows out to a collection using RegEx.

I’m validating using online tools to check the expressions - and while they work, both the Nintex nwc-tools regex test and the workflow fail the expressions.

https://regex101.com/

https://www.regextester.com/

and because one forum post suggested NWC used Ruby https://rubular.com/

Example of file rows

AB-CD-02-S.docx,Document Approver,abc\conman
PQ-RS-01-T.docx,Document Approver,abc\robber
WX-YZ-02-V.docx,Document Reviewer,abc\conman
 

Example of expressions which work in other portals

    (^[^abc\\][^\r\n]+)$

    (^[^c\\S][^\r\n]+)$

    ([^\r\n]+)$

These fail in Apply a regular expression | Platform Tools (nintex.com) with 

    "Error": { 

    "Code": "INTERNAL.ERROR",

    "Message": "Bad JSON escape sequence: \\c. Path 'input', line 2, position 51.",

which is \c in the first line.

 

Appreciate it if someone’s run into similar and has a workaround.

TIA
Rob

icon

Best answer by bsikes 28 February 2023, 16:26

View original

3 replies

Userlevel 4
Badge +10

Unfortunately, using the testing tool isn’t always a great test. NAC does alot of weird formatting stuff behind the scenes when it comes to escaping characters, and it seems that this is a situation where it handles it for you. The error you’re getting is referring to the “\c” in “abc\conman”, and I don’t get that when I actually use it in a workflow.  I used this regular expression: ([^\r\n]+)(\r|\n)*

 

 

Badge +2

Thank you, that’s a big step forward

Funny how 2 people can do the same thing, and get differrent results

 

Userlevel 4
Badge +10

It looks like you’re using the Split operation instead of the Extract operation. I’d try switching that and see if it fixes your issue. 

Reply