Koppelingen in nieuw tabblad openen
  1. Ongedaan maken
    Opnieuw uitvoeren
    Kopiëren
    Exporteren
    Herschrijven
    Testhulpmiddelen
    Meer acties
    • Werkrapport
    • E-mail
    • Herschrijven
    • Spraak
    • Titelgenerator
    • Slim antwoord
    • Gedicht
    • Opstel
    • Grap
    • Instagram-post
    • X-post
    • Facebook-post
    • Verhaal
    • Begeleidende brief
    • Hervatten
    • Taakbeschrijving
    • Aanbevelingsbrief
    • Ontslagbrief
    • Uitnodigingsbrief
    • Begroetingsbericht
    • Meer sjablonen proberen
  1. Lua’s string library offers a rich set of functions for manipulating and formatting strings beyond basic concatenation. Strings in Lua are immutable, so every operation returns a new string rather than modifying the original.

    Basic operations include:

    • string.len(s) → length of a string.

    • string.upper(s) / string.lower(s) → change case according to locale.

    • string.rep(s, n) → repeat a string n times.

    • Concatenation with .. operator.

    Substring extraction is done with string.sub(s, i, j), where indices start at 1 and can be negative to count from the end.

    s = "[in brackets]"
    print(string.sub(s, 2, -2)) -- in brackets
    Gekopieerd.

    Character and byte conversions use:

    • string.char(...) → integers to characters.

    • string.byte(s, i) → numeric code of character at position i.

    print(string.char(97)) -- a
    print(string.byte("abc", -1)) -- 99
    Gekopieerd.

    Searching and replacing:

    • string.find(s, pattern) → start and end indices of match.

    • string.gsub(s, find, replace) → replace occurrences (supports patterns).

    Feedback
  2. Lua - Strings - Online Tutorials Library

    Lua supports string to manipulate strings āˆ’ Now, let's dive into a few examples to exactly see how these string manipulation functions behave.
    Formatting Strings

    Many times in our programming, we may need to print strings in a formatted way. You can use the string.format function to format the output as shown below.

    Character and Byte Representations

    A sample code for character and byte representation, which is used for converting the string from string to internal representation and vice versa.

  3. Lua Strings - Lua | Version 5.4 Docs

    An overview of strings in Lua and their associated methods for manipulating string data.

  4. Understanding Lua Strings

    Despite being immutable, Lua provides several ways to manipulate strings through a variety of built-in functions. Some common operations include concatenation, finding substrings, replacing parts of a …

  5. String Manipulation and Formatting in Lua Programming Language

    27 feb. 2025 · Example of String Manipulation and Formatting in Lua Programming Language In Lua, strings are powerful and flexible, allowing you to manipulate and format text data with ease.

  6. Mastering Lua Strings: A Quick Guide to String …

    Lua strings are sequences of characters used for storing and manipulating text, often defined by enclosing characters within single or double quotes. Here's a …

  7. Programming in Lua : 20

    The string.char and string.byte functions convert between characters and their internal numeric representations. The function string.char gets zero or more integers, converts each one to a …

  8. Strings and Runes in Lua | Learn X By Example

    Lua is eight-bit clean: strings can contain any 8-bit character, and all string operations work with the whole string, regardless of its contents. String literals can be delimited by matching single or double …

  9. Kinda Technical | A Guide to Learning and Mastering Lua - String Basics

    Strings are a fundamental data type in Lua, allowing you to handle textual data efficiently. In Lua, strings are immutable, meaning that once created, they cannot be changed. This section will introduce you to …

  10. What are the basics of Lua strings? - Educative

    Strings are sequences of characters that store letters, numbers, symbols, and even whole sentences. Strings in Lua are immutable, which means that they can’t be changed once declared.

  11. Lua - Strings

    Lua provides powerful string manipulation capabilities through string literals, concatenation, pattern matching, and a comprehensive string library. This tutorial covers all aspects of working with strings …