尝试为Zapier创建正则表达式时出错

时间:2017-10-11 12:45:58

标签: javascript regex zapier

已解决:错误原因是我声明输出var的方式,请参阅代码

我正在尝试创建一个正则表达式来从VSTS附件获取URL以便与Jira同步。我尝试使用以下输入创建Run Javascript块:

Input Data

comment: 
creationDate: 2017-10-11T11:31:19.293Z
lastModifiedDate: 2017-08-29T12:32:51.393Z
location: https://project.visualstudio.com/_apis/wit/attachments/ca6206de-0fab-451a-b0bc-89e70221dfcb
name: Capture.PNG
resourceId: 2255679

我想要检索的是"位置",所以我认为这会产生诀窍:

var regEx = new RegExp('location: (.*)', 'g'); // As mentioned in the comments, the 'g' part is not needed
var path = regEx.exec(inputData);
// output = path[1]; This was failing miserably
var output = [{'path': path[1], 'hello': 'world'}] //This works just fine, I guess the hello world part is not really needed :)

但我总是收到错误:

TypeError: Cannot read property '0' of null

我已经尝试创建一个简单的javascript测试来运行相同的,它工作得很好。你能帮我吗?

0 个答案:

没有答案