我想针对 Gherkin 语法编写一个用于输入框验证的正则表达式。有效的示例输入如下所示:
Given I enter "www.google.com"
And enter keyword "new york"
When I click on "Images"
Then I can see "image list"
基本上,我正在尝试:任何情况(Given|When|And|Then)+String+"String in quotes"
我试过这个但不工作: (Given|When|And|Then)^[A-Za-z]+$/"(?:[^"\]|\.)*"/
创建了这样的表格
<body ng-app="app">
<form name="exampleForm" class="elegant-aero">
<label>Test Step:</label>
<input type="email" name="steps" ng-model="teststeps" ng-pattern="(Given|When|And|Then)^[A-Za-z]+$/"(?:[^"\\]|\\.)*"/" required/>
<div ng-messages="exampleForm.steps.$error">
<div ng-message="required">This field is required</div>
<div ng-message="pattern">Must be a valid gherkin syntax</div>
</div>
</form>
</body>