This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Cranium's profile picture

[Question] Help with string.match()

Started by Cranium, 17 August 2012 - 08:25 PM
Cranium #1
Posted 17 August 2012 - 10:25 PM
I am looking for where I can find the string.match() inputs(?) like %d+ , %a+, and the such, and what they mean. The purpose of this is to create a calculator within CC. I need to do string separation, but I don't know how. Anyone know where I can get a library of those or an easy to follow tutorial?
Grim Reaper #2
Posted 17 August 2012 - 10:30 PM
Check out this link.

Hope i helped! :(/>/>
Cranium #3
Posted 17 August 2012 - 11:00 PM
Also found(with extensive googling and CTRL+F'ing) this: http://www.lua.org/manual/5.1/manual.html
Section 5.4.1 tells me exactly what I needed.
Pharap #4
Posted 17 August 2012 - 11:06 PM
  • x: (where x is not one of the magic characters ^$()%.[]*+-?) represents the character x itself.
  • .: (a dot) represents all characters.
  • %a: represents all letters.
  • %c: represents all control characters.
  • %d: represents all digits.
  • %l: represents all lowercase letters.
  • %p: represents all punctuation characters.
  • %s: represents all space characters.
  • %u: represents all uppercase letters.
  • %w: represents all alphanumeric characters.
  • %x: represents all hexadecimal digits.
  • %z: represents the character with representation 0.
  • %x: (where x is any non-alphanumeric character) represents the character x. This is the standard way to escape the magic characters. Any punctuation character (even the non magic) can be preceded by a '%' when used to represent itself in a pattern.
Copied straight from lua.org (it was very hard to find in amongst all the text)
Cranium #5
Posted 17 August 2012 - 11:12 PM
That's why I had to use CTRL + F so much… Google doesn't like searching for them…
Pharap #6
Posted 17 August 2012 - 11:24 PM
That's why I had to use CTRL + F so much… Google doesn't like searching for them…

You'd think they could make it easier to read with a bit of JavaScript and a rewrite or something.
Lyqyd #7
Posted 18 August 2012 - 01:27 AM
Or you can use the index, and then scroll down to where it says "String Manipulation" and click on the subitem "Patterns".
Cranium #8
Posted 18 August 2012 - 01:41 AM
Well, with no coding history beyond Lua in CC, I had no idea what it was I was looking for(name), but I knew what I was looking for(characters)…. That sounds illogical, doesn't it?