Selenium Regex: Match literal string with dynamic date

半世苍凉 提交于 2021-02-11 14:28:23

问题


I'm writing some Selenium tests and need to confirm the presence of a text string that has dynamic date and currency components.

Example: "This is the date dd/dd/dd and this is the amount $ddd.dd."

Is this possible with the Selenium regex implementation?

Thanks, Richard


回答1:


If I'm not mistaken selenium supports the full power of javascript

  • Date dd/mm/yyyy

    01/01/1900 through 31/12/2099

    Matches invalid dates such as February 31st

    Accepts dashes, spaces, forward slashes and dots as date separators

    (0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}
    
  • Currency

    \$\d*(\.\d*)?
    


来源:https://stackoverflow.com/questions/10971209/selenium-regex-match-literal-string-with-dynamic-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!