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 to format strings in Java
- Does Python have a string ‘contains’ substring method?
- Convert bytes to a string
- How to convert a char to a String?
- Convert String to double in Java
- What is the difference between \r\n, \r, and \n? [duplicate]
- Convert bytes to a string
- Split a string using C++11
- How to read a text file into a string variable and strip newlines?
- Multiline string literal in C#
- How to convert an instance of std::string to lower case
- How do you reverse a string in-place in JavaScript?
- Splitting a string into separate variables
- What is the correct way to check for string equality in JavaScript?
- How do I convert a list of ascii values to a string in python?
- How to remove single character from a String
- Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects
- How to parse this string in Java?
- How can I concatenate str and int objects?
- What does the ‘b’ character do in front of a string literal?
- Best way to replace multiple characters in a string?
- Convert character to ASCII numeric value in java
- Lua Program Delay
- How do I create an array of strings in C?
- How to check if a string is a number?
- How to capitalize the first letter of a String in Java?
- Remove the first character of a string
- Check if a string contains another string
- std::string formatting like sprintf
- Sorting Characters Of A C++ String
- How can I remove a character from a string using JavaScript?
- Convert a list of strings to a single string
- In Java, how to append a string more efficiently?
- std::out_of_range error?
- Remove all special characters, punctuation and spaces from string
- How do I lowercase a string in C?
- Mixing a PHP variable with a string literal
- How can I match a string with a regex in Bash?
- How to trim whitespace from a Bash variable?
- How to check if type of a variable is string?
- Return char[]/string from a function
- What does ${} (dollar sign and curly braces) mean in a string in Javascript?
- “attempt to index a nil value”-error in Lua
- Center text in fixed-width field with stream manipulators in C++
- How to find char in string and get all the indexes?
- C# – Illegal characters in path
- Case-insensitive string comparison in C++
- Getting The ASCII Value of a character in a C# string
- How to create an array of strings in C?
- Hash function for a string
- Convert Int to String in Swift
- How can I get the last character in a string?
- Find the nth occurrence of substring in a string
- How to convert ‘binary string’ to normal string in Python3?
- What is the difference of pairs() vs. ipairs() in Lua?
- java.lang.NumberFormatException: empty String
- jQuery removing ‘-‘ character from string
- What’s the @ in front of a string in C#?
- Allocating string with malloc
- Hash function for a string
- Python: Converting string into decimal number
- Creating a comma separated list from IList
or IEnumerable - Ruby array to string conversion
- Why I cannot cout a string?
- difference between equals() and hashCode()
- How can I capture the result of var_dump to a string?
- PHP to write Tab Characters inside a file?
- How to convert string to boolean php
- How to delete specific characters from a string in Ruby?
- Regular expression – starting and ending with a character string
- How to change string into QString?
- Replace a character at a specific index in a string?
- How to remove part of a string?
- How to convert a String to CharSequence?
- Adding a newline into a string in C#
- How do I convert a String to a BigInteger?
- Converting String to Cstring in C++
- How to format a string as a telephone number in C#
- .NET String.Format() to add commas in thousands place for a number
- Replace all spaces in a string with ‘+’
- What does the Ruby method ‘to_sym’ do?
- How do I get the last character of a string?
- Cannot invoke toString() on the primitive type int
- What is a quick way to force CRLF in C# / .NET?
- How to compare character ignoring case in primitive types
- Insert string at specified position
- convert string to arraylist
in java - How to format strings using printf() to get equal length in the output
- Converting bool to text in C++
- Quotation marks inside a string
- Lua Semicolon Conventions
- Convert JSON String to JSON Object c#
- How to find and replace string?
- Convert Char to String in C
- Declaration is incompatible with type
- I’m getting the error “stoi is not a member of std” in myprogramminglab [duplicate]
- TypeError: coercing to Unicode: need string or buffer