Gsubbing multiple strings. (a lua only question)

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Gsubbing multiple strings. (a lua only question)

Post by rokit boy »

I need help, lets say I have a string...

Code: Select all

str = "abcdefghijklmnopqrstuvwxyzabcerasfdasgwrugherwiuogwabced"
and I wanna change all the a's,b's,c's,d's and e's to 1. How can I do that using gsub?
u wot m8
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Gsubbing multiple strings. (a lua only question)

Post by thelinx »

Code: Select all

str:gsub("[abcde]", "1")
User avatar
rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Re: Gsubbing multiple strings. (a lua only question)

Post by rokit boy »

thelinx wrote:

Code: Select all

str:gsub("[abcde]", "1")
It only works if I put it in this order. Any help?
u wot m8
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Gsubbing multiple strings. (a lua only question)

Post by thelinx »

What are you asking, exactly?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 232 guests