cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

JSON RegEx confusion

Jump to solution

Expression: (?<="FacilityId":")[\d\w-]+(?=",)

I also tried: (?<="FacilityId":")([^"]*)(?=")

Input: {"FacilityId":1,"PatientId":2323,"FirstName":"TEST"

Result: No matches

I'm trying to parse some returned JSON but I'm having a hard time doing so. I need an expression that will return the value of 1 from FacilityId, or value 2323 from PatientId. 

I looked at some other posts in the Nintex forums and thought I was getting somewhere but I can't seem to get it 100%. Can someone help me clear this up?

Tags (2)
Reply
4 Replies
Workflow Hero

Re: JSON RegEx confusion

Jump to solution

It would help to know a little more about your data, but I did come up with something that may work for you.

I've never liked lookahead or lookbehind regex. I read that it should work in the RegEx action, but it definitely doesn't work JavaScript. 

Maybe try this:

[^{"A-z":,]\d{0,4}

Here's the RegexTester link to show how it works: Parse JSON - Regex Tester/Debugger 

As long as the values you're trying to return are always numbers, this should work. If they can be longer than four digits, you can increase the {0,4} to whatever you need.




SharePoint 2013 On-Prem | Nintex Forms & Workflow Enterprise
Reply
Workflow Hero

Re: JSON RegEx confusion

Jump to solution

You could also use the patterns below with the RegEx action.

(?<=FacilityId\"\Smiley Happy[^\,]+‍
(?<=PatientId\"\Smiley Happy[^\,]+‍

You would need one Regular Expression action for each pattern above.  Each result would need to be stored in a collection variable, then retrieved using a Collection Operation action and stored in a workflow variable.

Reply
Workflow Hero

Re: JSON RegEx confusion

Jump to solution

Just to answer my own question here:

(?<="FacilityId"Smiley Happy(?<FacilityId>[\d\w-]+)(?=,)

Reply
Workflow Hero

Re: JSON RegEx confusion

Jump to solution

Yea, I found out the collection bit the other day. A little odd that it won't let you return the item to a single variable.

Reply