【问题标题】:What is a good regex to match for URLs in dataweave?什么是匹配 dataweave 中 URL 的好正则表达式?
【发布时间】:2021-12-26 10:04:10
【问题描述】:

我尝试使用类似的东西,但它不起作用。

%dw 2.0
var myString = "mycompany.com"
output application/json
---
{
    "match" : myString match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/),
}

【问题讨论】:

    标签: dataweave mulesoft


    【解决方案1】:

    我更新了您共享的正则表达式并将 ma​​tch 替换为 ma​​tches,因为您想根据正则表达式验证网址。

    %dw 2.0
    var myString = "https://www.mycompany.com"
    output application/json
    ---
    {
        "match" : myString matches (/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()\/@:%_\+.~#?&=]*)/)
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-24
      • 2022-01-24
      • 2011-03-16
      • 2014-07-25
      • 2019-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多