Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 正则表达式查找逗号,后跟花括号或常规括号_Regex - Fatal编程技术网

Regex 正则表达式查找逗号,后跟花括号或常规括号

Regex 正则表达式查找逗号,后跟花括号或常规括号,regex,Regex,我试图找到一个JavaScript问题,由于一些情况,我无法正确调试JavaScript。我觉得这个问题可能是因为在a]或}之前有一个逗号(,) 我可以在逗号和括号之间换行,也可以不换行。 所以我想做一个搜索。我不太擅长编写正则表达式,但我相信有一个简单的正则表达式可以帮助我做到这一点。 我将感谢任何帮助! 谢谢 使用前瞻,您可以通过以下方式检查: (?=,[\]\}]), (?=....) 'positive lookahead, meaning that it will only match

我试图找到一个JavaScript问题,由于一些情况,我无法正确调试JavaScript。我觉得这个问题可能是因为在a]或}之前有一个逗号(,) 我可以在逗号和括号之间换行,也可以不换行。 所以我想做一个搜索。我不太擅长编写正则表达式,但我相信有一个简单的正则表达式可以帮助我做到这一点。 我将感谢任何帮助!
谢谢

使用前瞻,您可以通过以下方式检查:

(?=,[\]\}]),
(?=....) 'positive lookahead, meaning that it will only match if text is followed by this
   ,[\]\}] is your lookahead pattern, this one means a comma followed by a ] or }
           , matches for the comma

您可以使用
[]
字符类构造在两个字符之间提供一个选项。以下是正则表达式:

,\n?[\]}]