Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-25-2021 01:28 PM
I am trying to clean a string read from LOAD CSV using pattern matching.
The idea was to use the following query
RETURN apoc.text.replace('Aglianico Del Vulture DOC Serpara 2010 Re Manfredi
!', '([\s\S]*?)(DOCG|DOP|DOC|IGP|IGT)/mig', '') AS output;
The expected result (tested on regex101) should be
Aglianico Del Vulture Serpara Re Manfredi
But the result from apoc is the same as input with absolutely no change.
Can someone explain and suggest a way to solve the problem?
Thank you
Solved! Go to Solution.
07-26-2021 09:19 AM
Ciao @p.dipietro ,
You can always change the last with in order to include a whole list.
with "(DOCG|DOP|DOC|IGP|IGT)" as bList
with "Aglianico Del Vulture IGP DOC Serpara 2010 Re Manfredi
!" as strg1, bList
with apoc.text.replace(strg1, '[^a-zA-Z]', ' ') as strg, bList
return trim(apoc.text.replace(strg, bList, ' ')) as final
Btw, are you sure that your Regex worked on regex101?
H
07-25-2021 10:20 PM
Try this:
with "Aglianico Del Vulture DOC Serpara 2010 Re Manfredi
!" as strg1
with apoc.text.replace(strg1, '[^a-zA-Z]', ' ') as strg
return apoc.text.replace(strg, 'DOC', ' ') as final
07-26-2021 08:01 AM
Thank you, but my problem is that I have different input strings, and must remove all the occurrences of DOCG|DOP|DOC|IGP|IGT case independently!
07-26-2021 09:19 AM
Ciao @p.dipietro ,
You can always change the last with in order to include a whole list.
with "(DOCG|DOP|DOC|IGP|IGT)" as bList
with "Aglianico Del Vulture IGP DOC Serpara 2010 Re Manfredi
!" as strg1, bList
with apoc.text.replace(strg1, '[^a-zA-Z]', ' ') as strg, bList
return trim(apoc.text.replace(strg, bList, ' ')) as final
Btw, are you sure that your Regex worked on regex101?
H
All the sessions of the conference are now available online