neo4j escaping for regular expressions
<p>I receive a user input <code>keyword</code> and want to use it to search my database. I built a query that looks something like this:</p>

<p><code>db.execute("MATCH (n:User) WHERE n.firstname CONTAINS {keyword} OR n.lastname CONTAINS {keyword} RETURN n.username", params);</code></p>

<p>But this isn't case sensitive, so I thought of manually building the expression and using regular expressions, sort of as follows:</p>

<p><code>db.execute("MATCH (n:User) WHERE n.firstname =~ '(?i).*" + keyword + ".*' OR n.lastname =~ '(?i).*" + keyword + ".*' RETURN n.username");</code></p>

<p>I'm looking either for a function for escaping the regex or a better solution for making the query case-insensitive. Any ideas?</p>