How can you find and replace a string?

How can you find and replace a string?
Im making a type-checker.

1 Like

What does that have to do with finding and replacing a string? Find/replace can be done with gsub.

1 Like

For this, use string.gsub.

-- example
local source = "all of these spaces will be replaced with underscores."

source = source:gsub("%s+", "_")
print(source) --> prints "all_of_these_spaces_will_be_replaced_with_underscores."

String patterns: String Patterns

1 Like