From d299b02b6cf3f14adf189e5c5db82106357445fb Mon Sep 17 00:00:00 2001 From: Rishabh Anand Date: Wed, 4 Dec 2024 16:47:20 +0530 Subject: [PATCH] improve regex --- src/utils.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 5837c15..b553bba 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,10 +1,9 @@ import { MarkerType } from "@xyflow/react"; import { Neo4jNode, Neo4jResponse } from "./NeoFlowViz"; -// Regex to match only nodes with defined variable names and optional types -export const nodeRegex = /\((\w+):?(\w+)?(?:\s*\{[^\}]*\})?\)/g; -// Regex to match only relationships with defined variable names and optional types -export const relationshipRegex = /\[(\w+):?(\w+)?(?:\s*\{[^\}]*\})?\]/g; +// Regex for nodes and relationships +export const nodeRegex = /\((\w+)?(:\w+)?(?:\s*\{[^\}]*\})?\)/g; +export const relationshipRegex = /\[(\w+)?(:[^\]]+)?(?:\s*\{[^\}]*\})?\]/g; function getResourceMappingFromQuery(query: string): { [key: string]: string } { let match: RegExpExecArray | null;