2016-09-22 51 views

回答

1

雖然並不完美,這是我一直在做。 (希望別人會跳和改進)

var Cypher = document.body.innerText 
 
Cypher = Cypher.replace(/(?:\s*(OPTIONAL MATCH|MATCH|WHERE|WITH|RETURN|DETACH DELETE|DELETE|UNWIND|CASE)\s*)/gi, function(match) { 
 
    return '\n' + match.toUpperCase() + ' ' 
 
}); 
 

 
Cypher = Cypher.replace(/(?:\s*(AND|NOT|DISTINCT)\s*)/gi, function(match) { 
 
    return ' ' + match.toUpperCase().trim() + ' ' 
 
}); 
 

 
Cypher = Cypher.replace(/(?:\s*(\w+)\(\s*)/gi, function(match) { 
 
    return ' ' + match.toUpperCase().trim() 
 
}); 
 

 
document.body.innerText = Cypher
match (n), (n)--(m) where n.car=1 and not n.id="rawr" with n.name return collect(n) as cars

JSFiddle version