正则表达式检查字符串中是否有许多字符

时间:2019-01-10 18:55:50

标签: regex

我非常喜欢这个,但是应该很容易。为了在其中一个电子邮件系统中创建规则,我需要提供一个RegEx,它将检查电子邮件标头的特定部分。因此,我想检查在由名称和电子邮件组成的一个字符串中@字符出现的次数是否超过10。

我尝试过使用^[@]{10,1}?,但对我来说不起作用,这实际上是检查我的字符串中是否有10个切线@

示例字符串为 John Doe<john.doe@.joe.com>,Jane Doe<jane.doe@jane.com>,Jack Doe<jack.doe@jack.com等。 如果@的出现次数超过10,我希望该表达式的值为true

1 个答案:

答案 0 :(得分:1)

您可以使用 (?:@.*?){10}@检查是否至少有11个 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "collectionTableViewCell", for: indexPath) as! CustomCollectionTableViewCell let temp = self.collections[indexPath.row].name cell.collectionTitle.text = temp return cell } 符号(因为您写了“超过10个”和“超过10个”)