Sorry, but I have another question. (Thanks for your reply)
I'm using starts with
command to match
WHERE n.test STARTS WITH 'match'
Which can result: match
, match2
, match3
, etc.
Now, if result matches. If it's match
, the result should be match2
. If it's match5
, the result should be match6
.
And if no matches, return match
So, how can we replace the result?
I guess, it should be added after the following line?
WITH collect(n) as nodesMatching
Thanks again.
Something like this?
replace(coalesce(nodesMatching[0].test, 'match'), /(\d+)$/, /(\d+)$/+1) as result
I know I'm doing it incorrectly. Please help on this. Also, I'm pretty sure that I'm using replace function in wrong line. Because, if I use in the preceding line, I have set 'match' as a default value. So, if no match, the result will be match2
if we do replace in that line which is not expected behavior. The reason is there's no match, we're just setting a default value 'match' to return as a result and the replace function will return it as match2
. In this case, it should return match
.