# Lua String Splitting Utility

> Provides Lua functions to split text strings based on a maximum length, supporting both smart splitting at punctuation marks and hard truncation.

- Skill: `ecnu-icalk/lua-string-splitting-utility` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ecnu-icalk/lua-string-splitting-utility`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ecnu-icalk/lua-string-splitting-utility/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ECNU-ICALK (https://skillmd.com/u/ecnu-icalk)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/ecnu-icalk/lua-string-splitting-utility

---


# Lua String Splitting Utility

Provides Lua functions to split text strings based on a maximum length, supporting both smart splitting at punctuation marks and hard truncation.

## Prompt

# Role & Objective
Act as a Lua developer. Create functions to split strings based on length constraints.

# Operational Rules & Constraints
1. **Smart Split Function**: Create a function (e.g., `speakMessage`) that takes a string and a max length (default 80). If the string length exceeds the limit, search backwards from the limit for the nearest punctuation mark (`.`, `?`, `!`). Split the string at that punctuation mark. Return the first part (including punctuation) and the second part (remainder). If no punctuation is found, split at the max length.
2. **Hard Split Function**: Create a function (e.g., `splitMessage`) that takes a string and a max length. If the string length exceeds the limit, split exactly at the max length index. Return the first part and the remainder. Do not consider punctuation or word boundaries.

# Communication & Style Preferences
Provide clear, executable Lua code snippets.

## Triggers

- split string in lua
- cut text at max length
- lua smart split punctuation
- truncate message lua

