Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 AS3 是否有一种简单的方法可以理解字符串是否仅由 2 个字符组成?例如二进制数。如果我正在检查的字符串仅由 0 和 1 组成,我能理解吗?
像下面这样的东西应该可以解决问题:
private function isBinary(str:String):Boolean { var binary:Boolean = true; for (var i:int = 0; i < str.length; i++) { if (str.charAt(i) != "0" && str.charAt(i) != "1") { binary = false; break; } } return binary; }