06-19-2018 12:57 PM
I have a mapper with json input like this:
$effective_code = “2138-HCOM-0546-01”
$course_code =“2138-HCOM-0546-01-12345|2138-HCOM-0546-EMR-12456”
I want an expression that will match “2138-HCOM-0546-01-12345” out of course code.
I don’t understand in a Snaplogic Mapper, how I can substitute the $effective_code into my regex match to execute as:
$COURSE_CODE.match(/2138-HCOM-0546-01-\d{5,}/g)
more generally:
$COURSE_CODE.match(/$effective_code-\d{5,}/g)
Anyone know how to do this?
Solved! Go to Solution.
06-19-2018 01:14 PM
The argument to match() takes a string that will be interpreted as a regular expression. So, you should be able to do:
$COURSE_CODE.match($effective_code + "-\\d{5,}")
06-19-2018 01:14 PM
The argument to match() takes a string that will be interpreted as a regular expression. So, you should be able to do:
$COURSE_CODE.match($effective_code + "-\\d{5,}")
06-20-2018 06:34 AM
@tstack, thanks, that worked. I find the documentation on match() a little confusing:
Mostly that it doesn’t return a String, it returns a RegExpResult, and that it can take either a quoted regex or a typical /regex/, maybe this could be clarified in the wiki?
Thanks for your help.
Mike
06-20-2018 08:53 AM
I’ve forwarded your request to the Doc team.