Capturing characters only after a specific character has appeared.

Posted by Wuggly on Fri 08 Jul 2016 08:01 PM — 6 posts, 21,855 views.

USA #0
Hello again,
I am currently trying to figure out how to gsub out a bunch of words if a specific character is in that line.

I've found some solutions in other languages, but not Lua and I can't quite figure out how to convert it over.

Here's one of the C# solutions.

string line = line.Substring(A.IndexOf('>') + 1);


And here's my failed attempt.. (although I never actually tested it)

line = string.gsub (line, ">", IndexOf(">") + 1)


Probably needs to be regex, but figured it wouldn't work anyways.

-Extra question since I'm apparently limited to 1 thread, although this probably doesn't need its own thread, and also cannot make anymore replies (Cannot create more threads today): Anyways, when is a plugin too big? Is that possible? I'm just wondering because my plugin has now reached over 6000 lines of code. Will I be able to keep going with it, or will I have to eventually split it up into multiple plugins?
Amended on Fri 08 Jul 2016 09:14 PM by Wuggly
Australia Forum Administrator #1
Quote:

Anyways, when is a plugin too big?


There is no specific limit. With loads of RAM on computers these days you can probably keep going. I must say that sounds fairly large, however.


Quote:

I am currently trying to figure out how to gsub out a bunch of words if a specific character is in that line.


I don't understand that. What do you mean by "gsub out a bunch of words if a specific character is in that line"? Can you give an example?
USA #2
ie:


x4444 y255 z1958 > Wuggly says, 'hi'.


So since there is a >, I am wanting to remove the > and everything before it, but keep everything after it.

I have a capture all trigger, and am wanting to be able to accomplish this within the function that trigger uses.

I have considered making another trigger, like * > * putting the second wildcard into a global variable, then when the capture all trigger/function detects the >, I could probably manipulate the line by doing something like line = wildcardglobalvar.

Was hoping there is another way to do this within the function of the capture all trigger that's already in place.

This isn't a big issue, I am just trying to cut down/shave/optimize my code some by doing it this way. Cause if there is a way to accomplish this, I will be able to cut out many other triggers I have.

EDIT: Haha yes, it is quite large, however it is mostly for visual stuff. A good bulk of it is from an interactive new settings menu I built for it, that lets you customize everything you see.
Here's a screenshot, just ignore the description part of the Sidebar Background, really need to go back and change that. But this is with everything open. Each window can be closed, and are animated when closing/opening. With everything closed, all you see is an open button to pull the sidebar out.
http://i.imgur.com/zOufv70.png
Amended on Sat 09 Jul 2016 05:19 PM by Wuggly
Australia Forum Administrator #3
A simple regexp will do that:


test = "x4444 y255 z1958 > Wuggly says, 'hi'."

foo = string.match (test, ".->(.*)")

print (foo)   -->  Wuggly says, 'hi'.
Australia Forum Administrator #4
Quote:

Here's a screenshot ...


Wow, MUSHclient scrubs up quite well, eh?
USA #5
As always, thank you again Nick! You've helped me get through roadblocks time and time again. So very much appreciated!

Just 6 months ago, I didn't know any Lua at all besides the very basic stuff that I learned when I first installed it (which was dec 25th last year) in order to make some aliases.

So that screenshot is proof how much of a help you and fiendish has been.

I hope one day to make a universal version of it so everyone can use it, but I still have a long list of things I plan to add to it before then.

Anyways, thanks again!