adam
adam

Reputation: 978

Is there a way to update or remove part of a property with cypher in neo4j

I'm currently working with a database of incident nodes that have a timestamp property. Some of the nodes have a correct timestamp, formatted this way:

"02:20:05"

Others are incorrectly formatted this way:

"T:02:20:05"

where the "T" was inadvertently captured in the upload. Is there a way in Cypher to do something like this:

MATCH (n)
WHERE n.Time =~ '(?i)T:.*'
REMOVE n.Time{T:} 
return n.Time

So that I can preserve the trailing timestamp data after the "T:" ?

Upvotes: 1

Views: 61

Answers (1)

cybersam
cybersam

Reputation: 67044

Try this:

MATCH (n)
WHERE n.Time =~ '(?i)T:.*'
SET n.Time = right(n.Time, length(n.Time)-2)
RETURN n.Time

Upvotes: 2

Related Questions