在黄瓜步骤定义中忽略带有正则表达式的字符
Ignore characters with regex in cucumber step definition
我正在尝试使用正则表达式捕获值中的数字,同时忽略字符。
特征步骤:然后第一个'elementName'重复组显示在'webPage'页面
我想从“1st”值中取出 '1' 并忽略字符串中剩余的字符。因为我对我想要实现的角色没有用。
当前步数:
Then(/the 'areaINeedHelp' '([^"]*)' repeating group is displayed on the '([^"]*)' page
您需要一个捕获数字但省略数字后缀的反向引用:
Then(/the '(\d+).{2}' '([^']*)' repeating group is displayed on the '([^']*)' page/
同时将其他两个反向引用中的 [^"]*
更改为 [^']*
,因为您在步骤参数周围使用单引号而不是双引号。
我正在尝试使用正则表达式捕获值中的数字,同时忽略字符。
特征步骤:然后第一个'elementName'重复组显示在'webPage'页面
我想从“1st”值中取出 '1' 并忽略字符串中剩余的字符。因为我对我想要实现的角色没有用。
当前步数:
Then(/the 'areaINeedHelp' '([^"]*)' repeating group is displayed on the '([^"]*)' page
您需要一个捕获数字但省略数字后缀的反向引用:
Then(/the '(\d+).{2}' '([^']*)' repeating group is displayed on the '([^']*)' page/
同时将其他两个反向引用中的 [^"]*
更改为 [^']*
,因为您在步骤参数周围使用单引号而不是双引号。