Jump to content




how to check if a string is blank

computer

  • You cannot reply to this topic
3 replies to this topic

#1 syfygirl

  • Members
  • 94 posts
  • LocationSomewhere in my mind, to which only makes sense to me.

Posted 30 April 2014 - 11:05 PM

hi there i have already done some deep digging for this question but can't find the answer. if you wanted to check if a string is blank, how would you do that?

something like this ?

if mystring == nil then
  print("True!")
end


#2 Agoldfish

  • Members
  • 451 posts
  • LocationSome Fish Bowl in Ohio.

Posted 30 April 2014 - 11:08 PM

Well, I don't knwo exactly how, but I know your method won't work. Assuming mystring exists, it will always be not nil. Well, except if mysting = nil is in there.

#3 CometWolf

  • Members
  • 1,283 posts

Posted 30 April 2014 - 11:13 PM

Like gold says, "" and nil is not the same. However, to determine if a string is emtpy, you can simply check it's length.
if #myString == 0 then


#4 syfygirl

  • Members
  • 94 posts
  • LocationSomewhere in my mind, to which only makes sense to me.

Posted 30 April 2014 - 11:14 PM

oh... sorry now i feel like this was a dumb question, thanks.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users