local s = "one;two;;four" local words = {} for w in (s .. ";"):gmatch("([^;]*);") do table.insert(words, w) end
By adding one extra ;
at the end of the string, the string now becomes "one;two;;four;"
, everything you want to capture can use the pattern "([^;]*);"
to match: anything not ;
followed by a ;
(greedy).
Test:
for n, w in ipairs(words) do print(n .. ": " .. w) end
Output:
1: one 2: two 3: 4: four
Related Posts:
- Lua String replace
- Lua string.format options
- Lua read beginning of a string
- How do I lowercase a string in Python?
- How do I convert a String to an int in Java?
- Logitech/LGHUB Lua – Loop with break
- How to format strings in Java
- How do I get a substring of a string in Python?
- Substring in excel
- Does Python have a string ‘contains’ substring method?
- Why the switch statement cannot be applied on strings?
- How does strtok() split the string into tokens in C?
- Convert bytes to a string
- Java – Convert integer to string [duplicate]
- Replacing instances of a character in a string
- Changing one character in a string
- How to read a file line-by-line into a list?
- What is lexicographical order?
- strip(char) on a string
- How to convert string to char array in C++?
- How can I convert a std::string to int?
- How to convert list to string [duplicate]
- Easiest way to convert int to string in C++
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- How to check whether a string contains a substring in JavaScript?
- Check if a string has a certain piece of text [duplicate]
- Converting integer to string in Python
- Reverse a string in Python
- How to split a string in Java
- How do I compare strings in Java?
- How to replace all occurrences of a string in JavaScript
- How do I compare two strings in python?
- std::string to char*
- How can I convert String to Int?
- How to convert a string to an integer in JavaScript?
- How to convert string to char array in C++?
- How to convert an int to string in C?
- C++ — expected primary-expression before ‘ ‘
- How can I do string interpolation in JavaScript?
- How to convert a char to a String?
- Regex not operator
- How to convert/parse from String to char in java?
- C++ string to double conversion
- How do I make the first letter of a string uppercase in JavaScript?
- Reverse a string in Java
- working of \n in python [duplicate]
- ValueError: could not convert string to float: id
- How do I make the first letter of a string uppercase in JavaScript?
- Regex not operator
- Print string to text file
- Reverse a string in Java
- What is a string of hexadecimal digits?
- Best way to convert string to bytes in Python 3?
- Pythonic way to create a long multi-line string
- Best way to convert string to bytes in Python 3?
- Does Python have a string ‘contains’ substring method?
- Extract a substring using PowerShell
- Java String Split by “|”
- Convert String to double in Java
- TypeError: not all arguments converted during string formatting python
- Conversion from string to char – c++
- How to convert an int to string in C?
- Array to String PHP?
- How can I exclude one word with grep?
- What is `CString`?
- Java String new line
- Creating multiline strings in JavaScript
- Extract substring in Bash
- Regex not operator
- ‘str’ object does not support item assignment
- How to check if a String contains another String in a case insensitive manner in Java?
- How do I append one string to another in Python?
- Java split string to array [duplicate]
- How to convert a string to integer in C?
- String concatenation: concat() vs “+” operator
- How to compare strings in Bash
- How do I append one string to another in Python?
- How do I check if a string contains a specific word?
- How to remove the last character from a string?
- Random string generation with upper case letters and digits
- How do I include the string header?
- How do I create an array of strings in C?
- How can I split and parse a string in Python?
- Creating multiline strings in JavaScript
- Split string into array
- How do I break a string in YAML over multiple lines?
- Java string to date conversion
- Differences between C++ string == and compare()?
- How to replace � in a string
- Change date format in a Java string
- How to convert a char array to a string?
- What are all the escape characters?
- node.js string.replace doesn’t work?
- Converting String to “Character” array in Java
- How to use operator ‘-replace’ in PowerShell to replace strings of texts with special characters and replace successfully
- How to read a text file into a string variable and strip newlines?
- What is the difference between \r\n, \r, and \n? [duplicate]
- How do I convert a double into a string in C++?
- Convert bytes to a string
- Split a string using C++11