|
| 20 Jan 2017 12:00 AM |
| So, I was trying to get a value of true or false using string.match("hey!","h") but it just printed h. Is there some sort of way I can check if a certain letter is in a sentence/number? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Jan 2017 12:01 AM |
| It returns nil if it isn't, so just check if it's not nil |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2017 12:14 AM |
| Thanks, I will check if that works! |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2017 12:15 AM |
How could that possibly not work?
|
|
|
| Report Abuse |
|
|
|
| 20 Jan 2017 12:21 AM |
| When I do this it returns false? print (string.match(numbar2/2, '.')== nil) btw numbar2 is 8 |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jan 2017 12:24 AM |
| Nevermind disregard this. I'm dumb. Thanks for the help |
|
|
| Report Abuse |
|
|
mani_fold
|
  |
| Joined: 23 Dec 2016 |
| Total Posts: 546 |
|
|
| 20 Jan 2017 12:24 AM |
Of course it returns false:
i) b/c 4 is not string, it's a number ii) even if it were, "4" and "." have nothing in common, so "string.match(4,".")==true" is not a true statement, it's false. |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2017 12:25 AM |
| I meant to do ~= nil when I was doing == nil |
|
|
| Report Abuse |
|
|
mani_fold
|
  |
| Joined: 23 Dec 2016 |
| Total Posts: 546 |
|
|
| 20 Jan 2017 12:27 AM |
| unless i'm wrong that should indeed throw true |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Jan 2017 12:49 AM |
You're wrong And you're also wrong about being wrong
string.match returns either anything matches or nil It won't return true or false But matching with "." will return the first character because . is a special character - it won't be true or false. |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2017 12:57 AM |
| Is there any way of finding if a number is a decimal after being divided, etc.. ? Because that is basically what I'm trying to do |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Jan 2017 12:59 AM |
if num % 1 ~= 0 then print("has a remainder") end |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2017 01:00 AM |
| Thanks, I was annoyed because I couldn't find this :P |
|
|
| Report Abuse |
|
|
mani_fold
|
  |
| Joined: 23 Dec 2016 |
| Total Posts: 546 |
|
|
| 20 Jan 2017 01:35 AM |
@cntkillme
You're wrong, read his code
he had a logical assertion being checked, not simply 'string.match'
hence, true/false would be returned, not true/nil |
|
|
| Report Abuse |
|
|
mani_fold
|
  |
| Joined: 23 Dec 2016 |
| Total Posts: 546 |
|
| |
|
mani_fold
|
  |
| Joined: 23 Dec 2016 |
| Total Posts: 546 |
|
|
| 20 Jan 2017 01:40 AM |
| i retract that, ############ is right |
|
|
| Report Abuse |
|
|
mani_fold
|
  |
| Joined: 23 Dec 2016 |
| Total Posts: 546 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Jan 2017 01:43 AM |
| don't you just love the filter |
|
|
| Report Abuse |
|
|
mani_fold
|
  |
| Joined: 23 Dec 2016 |
| Total Posts: 546 |
|
|
| 20 Jan 2017 01:56 AM |
| well i stylized your name in a way that i could see being a bit saucy |
|
|
| Report Abuse |
|
|