我正在尝试匹配以下格式的behat步骤(项目,电子邮件或客户端可以换成其他单词)。
I want to remove item 1
I want to remove email 4 from client 3
在SchemaContext中,我匹配以下内容:
/**
* @Given /^I want to remove (.+) (\d+)$/
* @Given /^I want to remove (.+) (\d+) from (.+) (\d+)$/
*/
public function iWantToRemove($object, $object_id, $parent = false, $parentId = false)
{
// Do stuff.
}
但是我收到了这个错误:
Ambiguous match of "I want to remove email 3 from client 4":
to `/^I want to remove (.+) (\d+)$/` from SchemaContext::iWantToRemove()
to `/^I want to remove (.+) (\d+) from (.+) (\d+)$/` from SchemaContext::iWantToRemove()
我正在努力找到正确的正则表达式/方法来正确匹配两种格式并通过相同的方法运行它们。我很感激任何指导。
答案 0 :(得分:1)
字符串I want to remove email 4 from client 3
确实与您的正则表达式匹配。我建议将第一个从/^I want to remove (.+) (\d+)$/
更改为/^I want to remove (\D+) (\d+)$/
。