generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Can someone explain to me the basics of Captures

Previous Thread :: Next Thread 
Riderj is not online. 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
crazytomato4 is not online. crazytomato4
Joined: 09 Feb 2011
Total Posts: 1368
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 is not online. 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
crazytomato4 is not online. crazytomato4
Joined: 09 Feb 2011
Total Posts: 1368
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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image