0

Can anybody point me in the right direction on how to use regex to replace a substring in a string using SharePoint workflow 2013?

I have an input field where the user potentially can enter characters which aren't valid in a folder name, now I don't want to limit the users input, but I need to strip the invalid characters from the folder name in order for it to be created.

0

You would put your REGEX in a variable and pass it to the match regular expression action in your workflow. Here is a link to help explain how to do it. Also, here is a REGEX tester I use to make sure you are getting the matches you are looking for. Good luck!

  • Yeah I'm with you that far, but that doesn't show how to do it when I want to replace characters using regex. Would you be able to show me how to do that? – Morten K Feb 12 at 16:28
  • I am not sure if you are going to be able to do a .replace within SPD workflows. You can create conditions and store variables with the text you want to replace it with. Not sure how dynamic you are wanting it, but if you know what you want to replace it with, you can store your replacements in variables and load them off of your REGEX matches. – lazoDev Feb 12 at 17:13
  • I'm quite experienced in creating workflows in SPD, and there is an action to do a replace substring in string - however I'm asking how to use that specifically together with REGEX. As far as I understand you havn't tried anything like that? – Morten K Feb 12 at 17:59
  • I sure haven't. To be honest, I use SPD workflows for basic operations and use code to do complex calculations that I would then pass into the list items to run the workflows with. I never trusted SPD workflows to work as I expected them to. You might could do something outside in JavaScript and push it to the workflow instead of having the workflow try to do it. I have had better luck doing it that way. Plus it is less strain on the farm with less WF processes queued in the timer job. – lazoDev Feb 12 at 18:05
  • My first comment was alluding to your comment above. I meant that I do not think SPD WF will allow you to do something like a .replace() with REGEX like you can in jQuery. A single match/replace method. Sorry if it was confusing. – lazoDev Feb 12 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.