如何使用 ruby​​/watir 验证网页文本,同时排除随机变量

发布于 2024-11-09 14:44:31 字数 484 浏览 0 评论 0原文

我有此文本,只需验证每行中的粗体字:

受保直接账单/ 16.67%: $xxx.xx 向下,包括保单费和财务责任费,以及 5分期付款 $xxx.xx(不包括 $x.xx 分期付款费用)

受保直接账单/25%:$xxx.xx 首付,包括政策费用和财务责任费,以及 5 期付款 $xxx.xx(不包括 $x.xx 分期付款费用)

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

我假设我需要使用:

foo = REGEX

@browser.text.include?(foo)

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

谢谢

I have this text and need to verify the bolded words only in each line:

Insured Direct Bill / 16.67%: $xxx.xx down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of $xxx.xx (does not include $x.xx installment fee)

Insured Direct Bill / 25%: $xxx.xx down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of $xxx.xx (does not include $x.xx installment fee)

Electronic Funds Transfer: $xxx.xx down, includes the Policy Fee and Financial Responsibility Fee, and 5 installments of $xxx.xx (does not include $x.xx installment fee)

I'm assuming I'll need to use:

foo = REGEX

@browser.text.include?(foo)

I'm stuck at how to get it to see everything other than the currency amounts. [^$\d+.\d+] excludes all the currency but includs the 5 and 16.67

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

各空 2024-11-16 14:44:31
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)
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)
挽清梦 2024-11-16 14:44:31

Marick 的书 Everyday Scripting with Ruby 中有一些正则表达式课程. 如果您需要不时使用正则表达式,我建议他们增强您的能力。

There are some regex lessons in Marick's book Everyday Scripting with Ruby. I recommend them to strengthen your capability if you need to use regex from time to time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文