Jump to content

Invalid pattern capture


Recommended Posts

Hello,

I've an error by using string.gsub because I want to remplace a string by another one but the script think it's a pattern but I don't want a pattern string.

The string that I want to remplace is ")" to " ". With string.find per example, he have an argument for disable the pattern.

  
local theString = "lolcats)are)awesome"; 
local result = string.gsub(theString, ")", " "); 
outputChatBox(result) 
  

The error that I've is "Invalid pattern capture".

Link to comment

From lua website:

Some characters, called magic characters, have special meanings when used in a pattern. The magic characters are

( ) . % + - * ? [ ^ $

You can fix that by adding "%" in front of the "magic" character, like this:

local result = string.gsub(theString, "%)", " "); 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...