Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:21:27+00:00 2026-05-26T02:21:27+00:00

I’m at a loss here, though I’ve been getting more and more familiar with

  • 0

I’m at a loss here, though I’ve been getting more and more familiar with gsub in Lua. There probably is a better way to do this more efficiently, and that’s what I’m looking for. What I’m wishing to do is change:

\(port Planes)9e;\(enter pool)n2euw

into

port Planes;run 9e;enter pool;run n2euw

It seems like it would be a simple thing, but I’m totally drawing a blank. I could probably attribute that partly to being exhausted, but that’s not really an excuse. The way I would have it is:

string.gsub(variable, ";","\(")
string.gsub(variable, "\(", ";")
string.gsub(variable, ")",";run")
string.gsub(variable, ";;",";")

But to me, that looks pretty sloppy, and not as efficient as I would like it to me. It also poses the problem if “)” ends the line, and it’d put “;” there, which is not something I want. I would appreciate the expertise of someone more familiar with Lua who can tidy this up and make it more efficient. I’ll be putting it into a function once all is said and done. Thanks!

Edit: Upon testing that, it doesn’t even work, anyway… and I can’t figure out the proper pattern matching sequence to use to make it work at all…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:21:28+00:00Added an answer on May 26, 2026 at 2:21 am

    Without knowing more about the possible combinations you could have, I can’t say that this would work in every instance but it should give a start:

    string.gsub(variable,"\\%((.-)%)","%1;run ")
    string.gsub(variable,";run $","")
    

    The first gsub is returning the commands inside your parenthesis, removing the parenthesis and adding ‘;run ‘ at the end.

    The second one is checking whether the end of the string is ‘;run ‘ and replacing it if that’s the case.

    You should also check out this article for a nice summary on patterns:
    http://www.lua.org/pil/20.2.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.