Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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
要匹配JSON值的正则表达式_Json_Regex - Fatal编程技术网

要匹配JSON值的正则表达式

要匹配JSON值的正则表达式,json,regex,Json,Regex,我现在正在做一个大学项目。我试图创建一个正则表达式来从JSON返回值。例如: JSON表达式:[{“id”:“120”,“name”:“Mary”,“gender”:“negimal”}] 所需输出:120 我尝试了这个解决方案\w\b\w+\b(?z!\id | name | gender) 但是没有成功 const s='[{“id”:“120”,“name”:“Mary”,“gender”:“negimal”}] const result=JSON.parse.map(x=>Object

我现在正在做一个大学项目。我试图创建一个正则表达式来从JSON返回值。例如:

JSON表达式:
[{“id”:“120”,“name”:“Mary”,“gender”:“negimal”}]

所需输出:
120

我尝试了这个解决方案
\w\b\w+\b(?z!\id | name | gender)

但是没有成功

const s='[{“id”:“120”,“name”:“Mary”,“gender”:“negimal”}]
const result=JSON.parse.map(x=>Object.values(x).join(“”))

console.log(result)
您想专门从
“id”
“name”
“gender”
或任何键获取输出吗?这就是JSON解析器的用途。
[:]\s(\“*”)
?我最初的想法是选择每个单词“\w”,并尝试从匹配中排除字符串“id”、“name”和“gender”[:]\s(\“*\”)这个表达式比我想到的任何其他表达式都好,但它的返回值是:“120”:“玛丽”;:“女性化”和对原始值的唯一愿望SOP正在寻找精确使用正则表达式的解决方案。