Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-16-2021 03:56 AM
When I use apoc.text.replace, I often wish to extract several values at once and immediately assign each to its own variable. I normally set up an assignment per variable like this:
UNWIND ["John Smith - Consultant",
"Willy Brown - Teacher",
"Jen Mack - Radiologist"] AS person
WITH apoc.text.replace(person, '(\w+)\s(\w+)\s-\s(\w)', '$1,$2,$3') AS extract
WITH split(extract,',')[0] AS first,
split(extract,',')[1] AS last,
split(extract,',')[2] AS role
RETURN first, last, role
...and that works fine, but I wish I could make that less verbose. I am open to any solution.
For example it would be great if I could do something like load the results directly into a map of named parameters like this:
UNWIND ["John Smith - Consultant",
"Willy Brown - Teacher",
"Jen Mack - Radiologist"] AS person
WITH apoc.text.replace(person, '(\w+)\s(\w+)\s-\s(\w)', {first:$1, last:$2, role:$3}) AS p
RETURN p.first, p.last, p.role
I'm open to anything that will make the code more concise.
Solved! Go to Solution.
03-16-2021 04:11 AM
03-16-2021 04:11 AM
03-17-2021 04:40 AM
Okay, thanks conker84. I don't see any other responses. So I'll do a feature request.
All the sessions of the conference are now available online