Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 21 Jan 2012 03:26 PM |
The wiki does not cover much, it shows more examples than the explanation of them.
[~ The key to programming is understanding it, not memorizing it. ~ AgentFireFox] |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2012 03:38 PM |
As in, string patterns?
I'm no expert on the terminology, but from what I know, a capture is the stuff that the string matching functions return (with the exception of string.gsub, which it does something else with). A capture, unless explicitly stated, is simply the entire pattern that you have the function searching for. To explicitly state captures, you use parenthesis, like so:
string.match(str, "(%w+)%p(%w+)")
That would return two strings, which would be the first match that the function found of any amount of alphanumeric characters (which would be the first string returned) followed by one punctuation character (which has to be there, but wouldn't be returned) followed by more alphanumeric characters (the second string returned). The function will return as many strings as there are captures, and as always, every single part of the pattern, whether it's in a capture or not, must be there for the function to return anything.
I dunno what else to say. What are you confused about? :L |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 21 Jan 2012 03:40 PM |
Example: for W in log.Value:gmatch("([%s%w%a%p%z]*) ") do
It is for a chat GUI that AFF made for me, I do not understand what it does. I am trying to use this to create a scrolling output for my Script Builder.
[~ The key to programming is understanding it, not memorizing it. ~ AgentFireFox] |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2012 03:44 PM |
| gmatch is an iterative function that will return the captures of each match that it finds of the pattern in the given string. The pattern `[%s%w%a%p%z]*` will match for all space characters, alphanumeric characters, letters, punctuation, and I think that %z is escape characters. So basically it matches for everything. Did AFF really write that? Because it seems like a pretty inefficient way to match for ".*", which I think is pretty much the same. :L |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 21 Jan 2012 03:44 PM |
Yeah lol, can go check it in his models XD
[~ The key to programming is understanding it, not memorizing it. ~ AgentFireFox] |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 21 Jan 2012 03:45 PM |
So can I keep that line and just plop it into my script for my output :S?
[~ The key to programming is understanding it, not memorizing it. ~ AgentFireFox] |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 21 Jan 2012 04:12 PM |
:O?
[~ The key to programming is understanding it, not memorizing it. ~ AgentFireFox] |
|
|
| Report Abuse |
|
|