---
title: extractUrl – ฟังก์ชันดึง URL จากข้อความ
url: https://www.thepexcel.com/functions/n8n/string-functions/extract-url-n8n/
type: function-explainer
program: n8n
syntax: extractUrl(text)
date: 2025-12-16
updated: 2025-12-17
scores:
  popularity: 6
  difficulty: 3
  usefulness: 6
---

# extractUrl – ฟังก์ชันดึง URL จากข้อความ

> ดึง URL จากข้อความ

## คำอธิบาย

extractUrl ดึงที่อยู่ URL จากข้อความหรือข้อมูล ฟังก์ชันนี้มีประโยชน์ในการสกัด URLs จากข้อความยาว ความเห็น หรือ log files

## Syntax

```excel
extractUrl(text)
```

**Variant**

```excel
$json.message.extractUrl()
```

ใช้เป็น method เมื่อ $json.message มี URL

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| text | Yes | string |  | ข้อความที่มี URL อยู่ข่างใน |

## เคสการใช้งาน

### สกัด URL จากความเห็น

ดึง URLs จากความเห็นหรือข้อความยาว

_เหมาะกับ:_ url-extraction

### ประมวลผล Log Files

ดึก URLs ที่มีปัญหาจาก error logs

_เหมาะกับ:_ log-processing

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: ดึง URL พื้นฐาน

```excel
{{ extractUrl('Check this out: https://www.example.com/page for more info') }}
```

**ผลลัพธ์:** `https://www.example.com/page`

ฟังก์ชันดึก URL 'https://www.example.com/page' จากข้อความ

### 2. ตัวอย่างที่ 2: ดึง URL จากข้อความยาว

```excel
{{ extractUrl($json.description) }}
```

**ผลลัพธ์:** `https://example.com/resource`

สูตรนี้ดึก URL จากฟิลด์ description

### 3. ตัวอย่างที่ 3: ดึก URL ที่ไม่มี Protocol

```excel
{{ extractUrl('Visit example.com today') }}
```

**ผลลัพธ์:** `example.com`

ดึก URL แม้ว่าจะไม่มี https:// prefix

## หมายเหตุเพิ่มเติม

⚠️ ฟังก์ชัน extractUrl() ค้นหา URL format ที่รู้จัก ใช้ร่วมกับ extractDomain() เพื่อดึงโดเมน หรือ isUrl() เพื่อตรวจสอบความถูกต้อง

## คำถามที่พบบ่อย

**Q: extractUrl() จะดึก URL ตัวแรกหรือทั้งหมด?**

ฟังก์ชันแบบมาตรฐานจะดึก URL ตัวแรก หากต้องการทั้งหมด ให้ใช้ regex หรือ split method

**Q: extractUrl() จะรับ URLs ที่ไม่มี protocol ได้หรือ?**

ได้ ฟังก์ชันจะพยายามค้นหา URLs แม้ไม่มี http:// หรือ https://

**Q: ใช้ extractUrl() เมื่อไหร่ในการทำงาน?**

ใช้เมื่อต้องดึก URLs จากข้อความ เช่นจากความเห็น, ข้อความ, หรือ log files

## ฟังก์ชันที่เกี่ยวข้อง

- [extractDomain – ฟังก์ชันดึงชื่อโดเมน](https://www.thepexcel.com/functions/n8n/string-functions/extract-domain-n8n/)
- [extractUrlPath – ฟังก์ชันดึง Path จาก URL](https://www.thepexcel.com/functions/n8n/string-functions/extract-url-path-n8n/)
- [isUrl – ฟังก์ชันตรวจสอบว่าเป็น URL ถูกต้องหรือไม่](https://www.thepexcel.com/functions/n8n/string-functions/is-url-n8n/)
- [split – ฟังก์ชันแยกข้อความจากตัวคั่น](https://www.thepexcel.com/functions/n8n/string-functions/split-n8n/)

## แหล่งข้อมูลเพิ่มเติม

- [n8n Expressions: extractUrl](https://docs.n8n.io/code/expressions/) _(documentation)_
- [String Extraction Functions](https://docs.n8n.io/code/builtin/overview/) _(guide)_

---

_Source: [https://www.thepexcel.com/functions/n8n/string-functions/extract-url-n8n/](https://www.thepexcel.com/functions/n8n/string-functions/extract-url-n8n/)_
