Thep Excel

endsWith – ฟังก์ชันตรวจสอบว่าข้อความสิ้นสุดด้วยข้อความที่กำหนด

endsWith ตรวจสอบว่าข้อความสิ้นสุดด้วยข้อความที่ระบุหรือไม่ ส่งคืนค่า true หรือ false ฟังก์ชันนี้มีประโยชน์ในการตรวจสอบนามสกุลไฟล์ ส่วนท้ายข้อความ หรือการจำแนกประเภท

=endsWith(text, searchString)

By ThepExcel AI Agent
16 December 2025

Function Metrics


Popularity
7/10

Difficulty
2/10

Usefulness
7/10

Syntax & Arguments

=endsWith(text, searchString)

Argument Type Required Default Description
text string Yes ข้อความที่ต้องการตรวจสอบ
searchString string Yes ข้อความท้ายสุดที่ต้องการค้นหา

How it works

ตรวจสอบนามสกุลไฟล์

ตรวจสอบว่าไฟล์เป็นนามสกุล .pdf, .docx หรือ .xlsx

ตรวจสอบท้ายสุด URL

ตรวจสอบว่า URL ลงท้ายด้วย /api หรือ /webhook

Examples

ตัวอย่างที่ 1: ตรวจสอบนามสกุล
{{ endsWith('document.pdf', '.pdf') }}
ไฟล์ 'document.pdf' สิ้นสุดด้วย '.pdf' จึงคืนค่า true
n8n Formula:

={{ endsWith('document.pdf', '.pdf') }}

Result:

true

ตัวอย่างที่ 2: ตรวจสอบประเภทไฟล์
{{ endsWith($json.filename, '.xlsx') || endsWith($json.filename, '.xls') }}
ตรวจสอบว่าเป็นไฟล์ Excel
n8n Formula:

={{ endsWith($json.filename, '.xlsx') || endsWith($json.filename, '.xls') }}

Result:

true

ตัวอย่างที่ 3: ตรวจสอบ Webhook
{{ $json.url.endsWith('/webhook') }}
ตรวจสอบว่า URL สิ้นสุดด้วย /webhook
n8n Formula:

={{ $json.url.endsWith('/webhook') }}

Result:

true

FAQs

endsWith() คำนึงถึง Case sensitivity หรือไม่?

ใช่ endsWith() คำนึงถึงตัวใหญ่-ตัวเล็ก เพื่อไม่สนใจให้แปลงเป็นตัวเดียวกันก่อน

endsWith() จะทำงานกับ empty string ได้หรือ?

ใช่ endsWith() จะคืนค่า true ถ้าค้นหา empty string เพราะทุกสตริงสิ้นสุดด้วย empty string

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

ใช้เมื่อต้องการตรวจสอบนามสกุลไฟล์ ส่วนท้ายข้อความ หรือรูปแบบท้ายสุด

Resources & Related

Additional Notes

endsWith เป็นฟังก์ชันที่ตรวจสอบว่าข้อความสิ้นสุดด้วยข้อความที่กำหนดหรือไม่ ใช้เมื่อต้องการตรวจสอบนามสกุลไฟล์ ท้ายสุดข้อความ หรือรูปแบบ

Leave a Reply

Your email address will not be published. Required fields are marked *