Regardless of the JSON object structure (simple or complex) what would be the ideal method to extract all urls from the following object into an array to iterate over in Javascript?

```
    {
    "url": "https://example.com:443/-/media/images/site/info",
    "data": [
        {
            "id": "da56fac6-6907-4055-96b8-f8427d4c64fd",
            "title": "AAAA 2021",
            "time": "",
            "dateStart": "2021-03-01T08:00:00Z",
            "dateEnd": "2021-12-31T15:00:00Z",
            "address": "",
            "geo": {
                "longitude": "",
                "latitude": "",
                "mapExternalLink": ""
            },
            "price": "Free Admission",
            "masonryImage": "https://example.com:443/-/media/images/site/siteimages/tcsm2021/fullwidthbanner/tcsmfullwidthicecream.ashx",
            "image": "https://example.com:443/-/media/images/site/siteimages/tcsm2021/fullwidthbanner/tcsmfullwidthicecream.ashx",
            "showDateInfo": false,
            "showDateInfoOnListings": false,
            "showTimeInfo": false,
            "showTimeInfoOnListings": false,
            "tags": [
                {
                    "key": "Lifestyle",
                    "name": "Lifestyle"
                }
            ],

            "partnerName": "",
            "sort_data": {
                "recommended": 0,
                "recent": 3,
                "partner": 0,
                "popular": 0
            }
        }
    ]
}

```

I would like to get the results in an array such as:

```
[
https://example.com:443/-/media/images/site/info,https://example.com:443/-/media/images/site/siteimages/tcsm2021/fullwidthbanner/tcsmfullwidthicecream.ashx,    https://example.com:443/-/media/images/site/siteimages/tcsm2021/fullwidthbanner/tcsmfullwidthicecream.ashx
]

```

I gather that i would need to apply some regex to extract the urls but not sure how to treat the json object as string for regex processing?
['https://Stackoverflow.com/questions/68397282', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/358649/']
I think the better and easier way is to stringfy given json into string and solve it by regex.
But still if you need to solve it by recursive, try the codes below:

```
const obj = {
    url: "https://example.com:443/-/media/images/site/info",
    data: [
      {
        id: "da56fac6-6907-4055-96b8-f8427d4c64fd",
        title: "AAAA 2021",
        time: "",
        dateStart: "2021-03-01T08:00:00Z",
        dateEnd: "2021-12-31T15:00:00Z",
        address: "",
        geo: {
          longitude: "",
          latitude: "",
          mapExternalLink: "",
        },
        price: "Free Admission",
        masonryImage:
          "https://example.com:443/-/media/images/site/siteimages/tcsm2021/fullwidthbanner/tcsmfullwidthicecream.ashx",
        image: "https://tw.yahoo.com",
        showDateInfo: false,
        showDateInfoOnListings: false,
        showTimeInfo: false,
        showTimeInfoOnListings: false,
        tags: [
          {
            key: "Lifestyle",
            name: "Lifestyle",
            link: "https://www.google.com",
          },
        ],

        partnerName: "",
        sort_data: {
          recommended: 0,
          recent: 3,
          partner: 0,
          popular: 0,
          anotherObj: {
            link: "https://www.github.com",
          },
        },
      },
    ],
  };
  function getUrl(obj) {
    const ary = [];
    helper(obj, ary);
    return ary;
  }

  function helper(item, ary) {
    if (typeof item === "string" && isUrl(item)) {
      ary.push(item);
      return;
    } else if (typeof item === "object") {
      for (const k in item) {
        helper(item[k], ary);
      }
      return;
    }

    return null;
  }

  function isUrl(str) {
    if (typeof str !== "string") return false;
    return /http|https/.test(str);
  }

  console.log(getUrl(obj));

```

But if you use this solution you need to transfer your json into js object
i'd agree to use a JSON parser, but if you want to do it with a regular expression, you might try this

```js
console.log(JSON.stringify({
  "url": "https://example.com:443/-/media/images/site/info",
  "data": [{
    "id": "da56fac6-6907-4055-96b8-f8427d4c64fd",
    "title": "AAAA 2021",
    "time": "",
    "dateStart": "2021-03-01T08:00:00Z",
    "dateEnd": "2021-12-31T15:00:00Z",
    "address": "",
    "geo": {
      "longitude": "",
      "latitude": "",
      "mapExternalLink": ""
    },
    "price": "Free Admission",
    "masonryImage": "https://example.com:443/-/media/images/site/siteimages/tcsm2021/fullwidthbanner/tcsmfullwidthicecream.ashx",
    "image": "https://example.com:443/-/media/images/site/siteimages/tcsm2021/fullwidthbanner/tcsmfullwidthicecream.ashx",
    "showDateInfo": false,
    "showDateInfoOnListings": false,
    "showTimeInfo": false,
    "showTimeInfoOnListings": false,
    "tags": [{
      "key": "Lifestyle",
      "name": "Lifestyle"
    }],

    "partnerName": "",
    "sort_data": {
      "recommended": 0,
      "recent": 3,
      "partner": 0,
      "popular": 0
    }
  }]
}).match(/(?<=")https?:\/\/[^\"]+/g));
```

`(?<=")https?:\/\/[^\"]+` basically finds patterns that start with a protocol scheme (http:// or https:// preceded by a `"` character) followed by anything that is *not* `"`