Path manipulation - How to?

  • 23 November 2022
  • 3 replies
  • 5 views

Badge +1

Hello

I call the SharePoint REST API to get a relative path to a library/subfolder

The return value is something like '/sites/site1/library1/subfolder1/subfolder2' however I need to remove the first two levels in order to construct another path. The path I need for the example is '/library1/subfolder1/subfolder2'

I have tried using regular expressions with named groups, but I did not succeed in that. Then I tried to split the path by the character '/', which I managed to do. However, I have no success in iterating 3 times removing the first element of the collection on each iteration.

 

Can someone please explain how to do this or another way to remove the first levels in the path.


3 replies

Userlevel 6
Badge +22

Hi,



Use the replace operation in a regular expression.
The pattern is:
^/w*/w*/


This will output:
library1/subfolder1/subfolder2
Replace it with /
To give you
/library1/subfolder1/subfolder2


Badge +1

Thank you for the suggestion. The RegEx actually works if I try it on regex101.com or if I run it with "Run now" option in Nintex Designer, but when I run the workflow the RegEx action outputs excactly the same string as the input. Any suggestions, how to fix this?

Userlevel 6
Badge +22

Hi,



I tested this in a published workflow.
And this was my result.
/library1/subfolder1/subfolder2


Reply