cancel
Showing results for
Did you mean:

## Regex matching "\text{Hom}(.+,.+)" does not work

Graph Buddy

Here's a screenshot showing everything:

As you can see my template_regex is:

\text\{Hom\}$$.+,.+$$


It's not matching either of the nodes shown in the lower right, but also shown in my front end (which I'm kind of showing off) here:

Those nodes exist in the Neo4j database, however, they're not being matched by this very basic regular expression.

1 ACCEPTED SOLUTION
Graph Buddy
def escape_regex_str(string):
string = string.replace('\\', r'\\\\')
string = string.replace("'", r"\'")
string = string.replace('{', r'\{')
string = string.replace('}', r'\}')
string = string.replace('(', r'$$') string = string.replace(')', r'$$')
return string


Fixed the problem by executing the query (copied from debug watcher in IDE) in Neo4j Desktop for better testing.

The top line of the above function solved the issue. Might be with t since escaping that is usually the tab character, so we need to double escape some of the backslashes. 🙂

def escape_regex_str(string):
string = string.replace('(', r'$$') string = string.replace(')', r'$$')

The top line of the above function solved the issue. Might be with t since escaping that is usually the tab character, so we need to double escape some of the backslashes. 🙂