Top "Lua-patterns" questions

Lua's native string pattern matching facility.

Lua String replace

How would i do this? I got this: name = "^aH^ai" string.gsub(name, "^a", "") which should return "Hi", but …

string replace lua gsub lua-patterns
Lua pattern matching vs. regular expressions

I'm currently learning lua. regarding pattern-matching in lua I found the following sentence in the lua documentation on lua.org: …

regex lua lua-patterns
Split a string using string.gmatch() in Lua

There are some discussions here, and utility functions, for splitting strings, but I need an ad-hoc one-liner for a very …

string lua lua-patterns
Finding '.' with string.find()

I'm trying to make a simple string manipulation: getting the a file's name, without the extension. Only, string.find() seem …

string lua lua-patterns
Modifying a character in a string in Lua

Is there any way to replace a character at position N in a string in Lua. This is what I've …

string lua gsub lua-patterns
What is the neatest way to split out a Path Name into its components in Lua

I have a standard Windows Filename with Path. I need to split out the filename, extension and path from the …

lua lua-patterns
Logical 'or' in Lua patterns?

Is it possible to achieve in Lua? local noSlashEnding = string.gsub("slash\\ending\\string\\", "\\|/$", "") -- noSlashEnding should contain "slash\\ending\\…

lua lua-patterns
Split a string by \n or \r using string.gmatch()

A simple pattern should do the job but I can't come up with/find something that works. I am looking …

string lua lua-patterns
Capitalize first letter of every word in Lua

I'm able to capitalize the first letter of my string using: str:gsub("^%l", string.upper) How can I modify …

lua lua-patterns
remove '$' characters from a string

I am trying to remove '$' signs from a string, but I am guessing it is some special char? …

regex string lua lua-patterns