rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 08 Aug 2011 07:08 PM |
If when I'm making my own string pattern, how would I make it search for multiple symbols? Like if you just do
print(("werere==wrewrewr"):find("=="))
it'll say
7 8
but how would I do this with a set? |
|
|
| Report Abuse |
|
|
| |
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Aug 2011 07:12 PM |
-_- not again.
@phoenix if you don't know anything about string patterns then you won't be any help with my question. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Aug 2011 07:18 PM |
Yet if you must know,
pattern="[qwerty]"
print(("qwertyvillage"):gsub(pattern,"A"))
Output : AAAAAAvillagA 7 |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 08 Aug 2011 07:21 PM |
"Explain 'Set'?"
"-_- not again."
xDDDDDDDDDDD I lol'd. And as always, I won't help at all. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Aug 2011 07:23 PM |
| I'll give you your hat back :O |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2011 07:44 PM |
| Sets are done with [], look at the qwerty example, any of those 6 letters will be replaced with A. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Aug 2011 07:47 PM |
@electric
do you have any idea how to do it? |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2011 08:07 PM |
| Yeah, I know string manipulation, one of the first 'advanced' things I learnt and the one I like the most still. :P |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Aug 2011 08:10 PM |
| I meant the original question, I could tell you knew string manipulation stuff with your first post. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2011 08:16 PM |
pattern = "[qwerty]" msg = "hello there my good friend, how are you?" a = 1 msg:gsub(pattern, function(b) a = msg:find(b, a) print(a) end) |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Aug 2011 08:22 PM |
| thanks, but it's still giving me 7,7 where I'm tryin to get 7,8. :/ |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Aug 2011 08:29 PM |
Like what I'm trying to do is get the following symbols
== != > >= < <=
out of strings so that I can easily compare them without a huge conditional statement, so I'm trying to use patterns. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2011 08:42 PM |
text = "" text:gsub("(%p)(%p-)", function(a, b) if a == "=" or a == "!" or a == ">" or a == "<" and not b then print() elseif a == "=" or a == "!" or a == ">" or a == "<" and b == "=" then print() end
And then you have to add what I added with the string.find x_x |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
| |
|