behat步骤的模糊正则表达式选择器
Ambiguous regex selector for behat step
我正在尝试以下列格式匹配 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()
我正在努力寻找正确的正则表达式/方法来正确匹配两种格式并 运行 通过相同的方法。如果有任何指导,我将不胜感激。
字符串 I want to remove email 4 from client 3
确实匹配您的两个正则表达式。我建议将第一个从 /^I want to remove (.+) (\d+)$/
更改为 /^I want to remove (\D+) (\d+)$/
。
我正在尝试以下列格式匹配 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()
我正在努力寻找正确的正则表达式/方法来正确匹配两种格式并 运行 通过相同的方法。如果有任何指导,我将不胜感激。
字符串 I want to remove email 4 from client 3
确实匹配您的两个正则表达式。我建议将第一个从 /^I want to remove (.+) (\d+)$/
更改为 /^I want to remove (\D+) (\d+)$/
。