如何检查角色的继承

时间:2015-09-01 14:57:10

标签: c# .net string

我想查看字符串中有多少个成功空格。它应该不超过一个。

例如:

this is ok
this  is NOT ok
thisisok
this   is NOT ok

2 个答案:

答案 0 :(得分:3)

您可以测试以查看字符串中是否存在两个连续的空格,因为它还将覆盖任何长于2的空格字符串。您可以使用Contains方法执行此操作:

string testString = "this  is not OK";
if (testString.Contains("  "))
{
    // Bad
}

答案 1 :(得分:0)

这应该为你提供字符串文字中继承空间的逻辑

    var myRestaurant: [String] = [String]()
//Getting the data from the PFQuery class
var query = PFQuery(className: "Restaurants")
        query.findObjectsInBackgroundWithBlock{
            (objects: [AnyObject]?, error: NSError?) -> Void in
            if error == nil {
                if let objects = objects as? [PFObject] {
                    for object in objects {

                        self.myRestaurant.append(object.objectForKey("ClassNameObject") as! String)

                  }

                }
            } else {
                println("errorin fetching restaurant block")
            }
        }