Skip to content

String Operations

Text manipulation: case conversion, split, pad, slugify, template, and more.

11 modules

ModuleDescription
ตัวพิมพ์เล็กแปลงข้อความเป็นตัวพิมพ์เล็ก
Pad StringPad a string to a specified length
แทนที่ข้อความแทนที่ข้อความย่อยในข้อความ
กลับด้านข้อความกลับด้านตัวอักษรในข้อความ
SlugifyConvert text to URL-friendly slug
แยกข้อความแยกข้อความเป็นอาร์เรย์โดยใช้ตัวคั่น
TemplateRender a template with variable substitution
ตัวอักษรใหญ่นำหน้าแปลงข้อความเป็นตัวอักษรใหญ่นำหน้า
ตัดช่องว่างลบช่องว่างจากหัวและท้ายข้อความ
Truncate StringTruncate a string to a maximum length
ตัวพิมพ์ใหญ่แปลงข้อความเป็นตัวพิมพ์ใหญ่

Modules

ตัวพิมพ์เล็ก

string.lowercase

แปลงข้อความเป็นตัวพิมพ์เล็ก

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-The text string to process

Output:

FieldTypeDescription
resultstringข้อความที่แปลงเป็นตัวพิมพ์เล็ก
originalstringข้อความที่แปลงเป็นตัวพิมพ์เล็ก
statusstringข้อความที่แปลงเป็นตัวพิมพ์เล็ก

Pad String

string.pad

Pad a string to a specified length

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-Text to pad
lengthnumberYes-Text to pad
pad_charstringNoTarget length
positionstringNoendCharacter to pad with

Output:

FieldTypeDescription
resultstringPadded string
originalstringPadded string
addednumberPadded string

แทนที่ข้อความ

string.replace

แทนที่ข้อความย่อยในข้อความ

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-The text string to process
searchstringYes-The substring to search for in the input text
replacestringYes-Text to replace matches with (leave empty to remove matches)

Output:

FieldTypeDescription
resultstringข้อความที่แทนที่แล้ว
originalstringข้อความที่แทนที่แล้ว
searchstringข้อความที่แทนที่แล้ว
replacestringข้อความอินพุตต้นฉบับ
statusstringข้อความค้นหาที่ถูกแทนที่

กลับด้านข้อความ

string.reverse

กลับด้านตัวอักษรในข้อความ

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-The text string to process

Output:

FieldTypeDescription
resultstringข้อความที่กลับด้าน
originalstringข้อความที่กลับด้าน
lengthnumberข้อความที่กลับด้าน

Slugify

string.slugify

Convert text to URL-friendly slug

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-Text to slugify
separatorstringNo-Text to slugify
lowercasebooleanNoTrueWord separator
max_lengthnumberNo0Convert to lowercase

Output:

FieldTypeDescription
resultstringMaximum slug length (0 = unlimited)
originalstringURL-friendly slug

แยกข้อความ

string.split

แยกข้อความเป็นอาร์เรย์โดยใช้ตัวคั่น

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-The text string to process
delimiterselect (,, ;, , , `
, , -, _`)NoCharacter(s) to split the string on

Output:

FieldTypeDescription
partsarrayอาร์เรย์ของส่วนที่แยก
resultarrayอาร์เรย์ของส่วนที่แยก
lengthnumberอาร์เรย์ของส่วนที่แยก
originalstringนามแฝงสำหรับ parts - อาร์เรย์ของส่วนที่แยก
delimiterstringจำนวนส่วนหลังจากแยก
statusstringข้อความอินพุตต้นฉบับ

Template

string.template

Render a template with variable substitution

Parameters:

NameTypeRequiredDefaultDescription
templatestringYes-Template string with {{variable}} placeholders
variablesobjectYes-Variables to substitute
missing_valuestringNo-Value for undefined variables
preserve_missingbooleanNoFalseValue for undefined variables

Output:

FieldTypeDescription
resultstringKeep placeholder if variable is missing
replacednumberRendered template
missingarrayRendered template

ตัวอักษรใหญ่นำหน้า

string.titlecase

แปลงข้อความเป็นตัวอักษรใหญ่นำหน้า

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-The text string to process

Output:

FieldTypeDescription
resultstringข้อความที่แปลงเป็นตัวอักษรใหญ่นำหน้า

Example: Convert to title case

yaml
text: hello world from flyto

Example: Format name

yaml
text: john doe

ตัดช่องว่าง

string.trim

ลบช่องว่างจากหัวและท้ายข้อความ

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-The text string to process

Output:

FieldTypeDescription
resultstringข้อความที่ตัดช่องว่างแล้ว
originalstringข้อความที่ตัดช่องว่างแล้ว
statusstringข้อความที่ตัดช่องว่างแล้ว

Truncate String

string.truncate

Truncate a string to a maximum length

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-Text to truncate
lengthnumberYes-Text to truncate
suffixstringNo...Maximum length
word_boundarybooleanNoFalseText to append if truncated

Output:

FieldTypeDescription
resultstringBreak at word boundary
originalstringTruncated string
truncatedbooleanTruncated string
removednumberOriginal string

ตัวพิมพ์ใหญ่

string.uppercase

แปลงข้อความเป็นตัวพิมพ์ใหญ่

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-The text string to process

Output:

FieldTypeDescription
resultstringข้อความที่แปลงเป็นตัวพิมพ์ใหญ่
originalstringข้อความที่แปลงเป็นตัวพิมพ์ใหญ่
statusstringข้อความที่แปลงเป็นตัวพิมพ์ใหญ่

Released under the Apache 2.0 License.