Extract URL

May I know, what is the easier way to extract the URL out from the JSON result?

Example From:

text:https://www.facebook.com/121790674546188_5691115404280326|AsiaOne\n\nAnalysts are already forecasting property price increases of up to 3% for some of these areas with the announcement. By the time the stations are completed in 2032, they estimate a 5-15% increase.

I only want the URL potion without the |AsiaOne

Hey @Issac_Chua,

Welcome to the community :cake:

As a quick solution you could use .split() and split on the | so you would have something like {{ $json["text"].split('|')[0] }} which would return the URL and if you used {{ $json["text"].split('|')[1] }} you would get the rest of the data.

Thank you Jon, let me go try it out :slight_smile:

1 Like

Hi Jon,

The code work, however, I have another entry, and the result appears to be

@asiaonecom <3 insights from the recently announced Phase 2 Cross Island Line MRT stations you might have missed, Money News - AsiaOne

This is after using the .spilt, so how can I further remove away the @asiaonecom <

Would appreciate if you can give me some advice. Thank you.

Hey @Issac_Chua,

Looks like we might need to get a bit more creative :slight_smile: do you have a more complete list of data I can play with?

Hi Jon,

Here the full json result:

[
{
“type”: “message”,
“subtype”: “bot_message”,
“text”: “@asiaonecom <https://www.asiaone.com/money/3-insights-recently-announced-phase-2-cross-island-line-mrt-stations-you-might-have-missed|shared a link>”,
“ts”: “1663893182.383489”,
“username”: “Spike”,
“icons”: {
“image_48”: “https://s3-us-west-2.amazonaws.com/slack-files2/bot_icons/2022-07-12/3804335430289_48.png
},
“bot_id”: “B03P311BLMC”,
“app_id”: “A0BG8ASDC”,
“attachments”: [
{
“id”: 1,
“thumb_height”: 509,
“thumb_width”: 763,
“thumb_url”: “https://external-iad3-1.xx.fbcdn.net/emg1/v/t13/7219962841371430902?url=https%3A%2F%2Fwww.asiaone.com%2Fsites%2Fdefault%2Ffiles%2Fstyles%2Fa1_og_image%2Fpublic%2Foriginal_images%2FSep2022%2F20220922_map_99.co_.jpg%3Fitok%3DZS4nZ9VC&fb_obo=1&utld=fbcdn.net&stp=dst-emg0_q75&ccb=13-1&oh=06_Aaqv86W2uLEOMN8ydlmwAybFd_l16mCuSefPK8_Aiaaf8g&oe=632E87ED&_nc_sid=5f3a21”,
“fallback”: “AsiaOne posted this link”,
“text”: “https://www.facebook.com/121790674546188_5691115404280326|AsiaOne\n\nAnalysts are already forecasting property price increases of up to 3% for some of these areas with the announcement. By the time the stations are completed in 2032, they estimate a 5-15% increase.\n\nTriggered by AM”,
“footer”: “Shares: 0 | Comments: 0 | Reactions: 0”
}
]
}
]

Hey @Issac_Chua,

Give this a bash, There is an expression in the Set node that would do it or a function for if anything gets crazier.

Ok, Thanks Jon. I will give it a try

1 Like

Hi Jon, I am trying to retain this part of the message. Been trying to play around with the code… but not be able to get any closer or success. Any advice?

Try {{ $json["attachments"][0]["text"].split('\n\n')[1] }}, With that data we can split on the new line characters. That will then get you something like this

Thanks, Jon. I am all good now.

1 Like