Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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
Javascript正则表达式:在URL中查找GUID并替换它_Javascript_Regex_Replace - Fatal编程技术网

Javascript正则表达式:在URL中查找GUID并替换它

Javascript正则表达式:在URL中查找GUID并替换它,javascript,regex,replace,Javascript,Regex,Replace,我有如下URL: document.URL.replace(/regexp goes here/, 'newGUID'); GUID是我需要查找和替换的ID GUID被剥离,没有破折号,正好32个字符,小写a-f,0-9。像这样: 961b7d0e50f0462a8828c31bf0874a71 找到后,我会这样替换它: document.URL.replace(/regexp goes here/, 'newGUID'); 您可以尝试以下方法: str.replace(/\b[a-f\

我有如下URL:

document.URL.replace(/regexp goes here/, 'newGUID');

GUID是我需要查找和替换的ID

GUID被剥离,没有破折号,正好32个字符,小写a-f,0-9。像这样:

961b7d0e50f0462a8828c31bf0874a71
找到后,我会这样替换它:

document.URL.replace(/regexp goes here/, 'newGUID');

您可以尝试以下方法:

str.replace(/\b[a-f\d]{32}\b/, 'newGUID');

从这个答案中可以看出


你能解释一下
a-z\d
部分吗?请注意,GUID在字母表中只包含从A到F的字符,不包含更多字符。我的错,以为你说的是A-z,已更新
小写a-f,0-9
[a-f\d]
匹配的,
\d
[0-9]
相同,只是更短。