Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 20 Jul 2013 04:24 PM |
| What does the string pattern "+" do? (Zars, after looking at wiki. I was wrong about it..) |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2013 04:26 PM |
| It matches 1 or more of the characters specified. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 20 Jul 2013 04:27 PM |
| Yeah, i wouldn't have come here if i didn't look up on wiki. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 20 Jul 2013 04:29 PM |
| Meaning, I must have another explonation then that... |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 20 Jul 2013 06:30 PM |
+ matches one or more characters.
local String = "ABC123DEF456"
print(String:match("%a")) --> A print(String:match("%a+")) -->ABC |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 21 Jul 2013 07:07 AM |
| So...We always need the + pattern in a pattern? like if we wanted a full match? |
|
|
| Report Abuse |
|
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 21 Jul 2013 09:50 AM |
⚽⚾🎾🎱🏉🏈🏀🎳...wait, what?
Anyway, yes. If you want a full match, use +. If you don't, do not. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 10 Aug 2013 01:38 PM |
Yes, i'm bumping this so i don't need to ask on a new thread. Anyway, why does it only get the first match without the + pattern? like why does it happen without it?
Also, i have gotten the + pattern like this:
When i do a string pattern for some reason it only returns the first character match. |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2013 01:39 PM |
| Did you enclose it with ( and )? |
|
|
| Report Abuse |
|
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 10 Aug 2013 03:34 PM |
Yes but according to you, and that other guy
local String = "ABC123DEF456"
print(String:match("%a")) --> A print(String:match("%a+")) -->ABC
When i have a pattern, it only returns the first character match if i don't use the + pattern??? |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2013 03:54 PM |
for k in String:gmatch("(%a+)") do print(k) end |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2013 04:10 PM |
Okay, %a is any letter. So it gets the first letter from the string.
print(("abc123def"):match("%a")) >a print(("abc123def"):match("%a+")) >abc
+ returns all the letters(whatever you used) that are contiguous.
print(("abc1 123 def"):match("%w")) >a print(("abc1 123 def"):match("%w+")) >abc1
for match in ("abc1 123 def"):match("%w") do print(match) end >a, b, c, 1, 1, 2, 3, d, e, f
for match in ("abc1 123 def"):match("%w+") do print(match) end >abc1, 123, def |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 10 Aug 2013 04:27 PM |
| I'm still at where i started. Why won't it give a full match without the +? |
|
|
| Report Abuse |
|
|