well, im making a custom emulator and i was wondering, how to make a custom command?string.find would WORK but not as i was hoping. if im trying to find code in the middle of something like /*test*\ then i couldn't do this correctly. help?
welp...im dumb
Started by SpencerBeige, Mar 08 2015 12:57 AM
4 replies to this topic
#1
Posted 08 March 2015 - 12:57 AM
#2
Posted 08 March 2015 - 01:32 AM
You're probably looking for string.match().
Take a look at patterns and the string library in general. The last link will definitely make things clearer.
Regarding "/*text*\" the pattern to get test would be relatively simple:
Take a look at patterns and the string library in general. The last link will definitely make things clearer.
Regarding "/*text*\" the pattern to get test would be relatively simple:
local a = "/*test*\\" print( a:match( "/%*(.-)%*\\" ) )
#3
Posted 08 March 2015 - 01:54 AM
wieselkatze, on 08 March 2015 - 01:32 AM, said:
You're probably looking for string.match().
Take a look at patterns and the string library in general. The last link will definitely make things clearer.
Regarding "/*text*\" the pattern to get test would be relatively simple:
Take a look at patterns and the string library in general. The last link will definitely make things clearer.
Regarding "/*text*\" the pattern to get test would be relatively simple:
local a = "/*test*\\" print( a:match( "/%*(.-)%*\\" ) )
edit: also, do you know of a pattern generator? i could figure it out if i wanted, but its still a bit hard...
Edited by slow-coder, 08 March 2015 - 01:56 AM.
#4
Posted 08 March 2015 - 11:55 AM
slow-coder, on 08 March 2015 - 01:54 AM, said:
wieselkatze, on 08 March 2015 - 01:32 AM, said:
You're probably looking for string.match().
Take a look at patterns and the string library in general. The last link will definitely make things clearer.
Regarding "/*text*\" the pattern to get test would be relatively simple:
Take a look at patterns and the string library in general. The last link will definitely make things clearer.
Regarding "/*text*\" the pattern to get test would be relatively simple:
local a = "/*test*\\" print( a:match( "/%*(.-)%*\\" ) )
edit: also, do you know of a pattern generator? i could figure it out if i wanted, but its still a bit hard...
#5
Posted 08 March 2015 - 12:01 PM
There is also a pure-lua implementation of LPeg which is an advanced implementation of Lua's pattern matching library. Its pretty powerful though potentially slow.
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











