ポスト #1 · 2016-07-27 11:00:35pmにポスト 8.1年前
Th3_Ov3rHell_3XoduZ | |
---|---|
Member | |
313 ポスト | |
Reg. 2012-09-13 | |
"ITG, The Best Dance Machine!" |
I am doing something on my theme, and I got stuck on the following: I need that using string.match, I match the exact pattern, those patterns are "1000", "0100", "0010" and "0001" at the moment. And im not sure how to do it properly. This cuz, I am having falses matches due to the string I am using to match contains 1s and 0s. But I want the exact pattern. Not cuz the string contain 1s and 0s in any order.
In short I wanna match: "1000" and not "0001" cuz the string contains just the 1 and 0 on it.
Im not sure if I explained it correctly. Anyway, any help is very appreciated.
PD: I am doing something that involves the Song's charts, thats why "1000", "0100", etc.
In short I wanna match: "1000" and not "0001" cuz the string contains just the 1 and 0 on it.
Im not sure if I explained it correctly. Anyway, any help is very appreciated.
PD: I am doing something that involves the Song's charts, thats why "1000", "0100", etc.
ポスト #2 · 2016-07-28 12:05:49amにポスト 8.1年前
MadkaT | |
---|---|
Member | |
824 ポスト | |
Not Set | |
Reg. 2009-11-24 | |
If you are searching just one step in a row, could test this:
If returns a value bigger than 1 it includes multiple steps.
I you need to test if the string starts with '10'
If returns something, the string starts with 10, if not i will return a nil value.
string.match("0010", '(1+)')
If returns a value bigger than 1 it includes multiple steps.
I you need to test if the string starts with '10'
string.match("1100", '^10')
If returns something, the string starts with 10, if not i will return a nil value.
ポスト #3 · 2016-07-28 05:53:47pmにポスト 8.1年前
Th3_Ov3rHell_3XoduZ | |
---|---|
Member | |
313 ポスト | |
Reg. 2012-09-13 | |
"ITG, The Best Dance Machine!" |
No, I am not trying to match a step on a line/row. I am trying to identify every arrow on a stepchart. That's why I need to match the exact pattern to identify what Arrow it is.
1000 > Left
0100 > Down
0010 > Up
0001 > Right
Thats why, the pattern "10", will match the four lines, etc.
1000 > Left
0100 > Down
0010 > Up
0001 > Right
Thats why, the pattern "10", will match the four lines, etc.
ポスト #4 · 2016-07-29 01:53:43amにポスト 8.1年前
Then you can ask the position of the arrow, and determine the direction with the result
In this case 1 = Left
2 = Down
3 = Up
4 = Right
local position = string.find("0100", '1');
return position;
return position;
In this case 1 = Left
2 = Down
3 = Up
4 = Right
ポスト #5 · 2016-07-29 06:45:35pmにポスト 8.1年前
Th3_Ov3rHell_3XoduZ | |
---|---|
Member | |
313 ポスト | |
Reg. 2012-09-13 | |
"ITG, The Best Dance Machine!" |
Quote: MadkaT
Then you can ask the position of the arrow, and determine the direction with the result
In this case 1 = Left
2 = Down
3 = Up
4 = Right
local position = string.find("0100", '1');
return position;
return position;
In this case 1 = Left
2 = Down
3 = Up
4 = Right
Right, the solution was always so simple. Thanks you a lot.