ruby - 如何在使用 ruby​​/watir 排除随机变量的同时验证网络文本

标签 ruby regex watir

我有这段文字,只需要验证每一行中的粗体字:

Insured Direct Bill/16.67%: $xxx.xx down,包括保单费和财务责任费,以及 5 期 $xxx.xx(不包括 $x.xx 分期付款)

Insured Direct Bill/25%:首付 $xxx.xx,包括保单费和财务责任费,以及 $xxx.xx 的 5 期分期付款(不包括 $x.xx 分期付款费)

电子资金转账:$xxx.xx首付,包括保单费和财务责任费,分5期$xxx.xx(不包括$x.xx分期费)

我假设我需要使用:

foo = 正则表达式

@browser.text.include?(foo)

我不知道如何让它看到货币金额以外的所有内容。 [^$\d+.\d+] 不包括所有货币,但包括 5 和 16.67

谢谢

最佳答案

regex = /Insured Direct Bill \/ 25%: \$(\d+\.\d+) down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of \$(\d+\.\d+) \(does not include \$(\d+\.\d+) installment fee\)/

@browser.text.match(regex)

关于ruby - 如何在使用 ruby​​/watir 排除随机变量的同时验证网络文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6113973/

相关文章:

ruby-on-rails - 我如何强制 Rails 使用我想要的 Ruby 版本(由 rbenv 管理)?

Ruby 函数列表文件递归

ruby - 在 Ruby 中计算导数 ([i] - [i - 1])

正则表达式根据文件扩展名列表获取文件名

Java 正则表达式

webdriver - watir-webdriver 在沉重的页面上通过正则表达式定位元素非常慢

windows - 在 Windows XP 上安装 watir-webdriver 时出现 `marshal data too short` 错误消息

selenium - Watir - 驱动 Chrome 时 file_field 调用点击了错误的元素

ruby - 如何在 Ruby 的循环中跳过几次迭代?

javascript - 使用正则表达式构建定界符解析器时第一个空白值的问题